Macro to render external JSON data?
Asked by Rune Hellem:

Anyone aware of a macro for Confluence that I can use to render json content, collected from a url? Have several json-files used to prepare various stuff such as DNS-aliases (easier to provide commands for the domain admins than a list of manual tasks).

But for documentation purposes, for all to know which aliases we have, I would like to render this on a page in Confluence.


Answers:
author: Katerina Rudkovskaya [Stiltsoft]
body: Hello [@Rune Hellem](/t5/user/viewprofilepage/user-id/702569) ,  

You can try the [Table from JSON](https://docs.stiltsoft.com/pages/viewpage.action?pageId=58427709) macro, which is released in the 6.3.0 version of [Table Filter and Charts for Confluence](https://marketplace.atlassian.com/apps/27447/table-filter-and-charts-for-confluence?hosting=cloud&tab=overview).  

With the help of this app, you can also filter any kind of data, summarize it and visualize with dynamically updated charts.   

Katerina  
Stiltsoft

comments: author: cuong hoang
body: I found that the JSONPath selection is pretty limited, I believe the data has to be in array format only, can't select specific attributes.

When combining with Table Transformer, we still can't select the attributes since that doesn't have any (documented) function for working with json objects.


author: Katerina Rudkovskaya [Stiltsoft]
body: Hi [@cuong hoang](/t5/user/viewprofilepage/user-id/754920) ,  

Yes, you shoud set the path to the array.   

Could you please send us your JSON file to our **[support](https://jsd.stiltsoft.com/servicedesk/customer/portal/2)** and clarify what you try to reach with Table from JSON and Table Transformer?

Katerina  
Stiltsoft


author: Katerina Kovriga {Stiltsoft}
body: Hi [@Rune Hellem](/t5/user/viewprofilepage/user-id/702569) ,

Try the [Table Filter and Charts for Confluence](https://marketplace.atlassian.com/apps/27447/table-filter-and-charts-for-confluence?hosting=server&tab=overview) app and its [Table from JSON](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Table+from+JSON+macro) macro.

The macro allows you to output a table from JSON data source (URL or an attached file).


author: Sven Schatter _Lively Apps_
body: Hi [@Rune Hellem](/t5/user/viewprofilepage/user-id/702569),

So, since pulling JSON files that are hosted somewhere is pretty much equivalent to a REST GET request, you could use our app [PocketQuery](https://marketplace.atlassian.com/apps/1211199/pocketquery-for-confluence-sql-rest?utm_source=atlcom) for it. The thing about PocketQuery is that it tries to display your JSON as a table per default which means it expects it to be in this layout:

```
[
  {"columnA": 1, "columnB": 2, ...}, // row 1
  {"columnA": 10, "columnB": 20, ...}, // row 2
  ...
]
```

PocketQuery however allows you to write Converter functions which let you transform your JSON into something that can be displayed as a table with a few lines of JavaScript. If you have any questions about it don't hesitate to ask here or raise a ticket at our [ServiceDesk](https://go.livelyapps.com/support) - we're happy to help! :)

Cheers,  
Sven

P.S. If you want a small example of how you could set this up I recommend reading [this blog post](https://livelyapps.com/blog/2020/08/pocketquery-best-practice-secure-reports-with-rest-apis?utm_source=atlcom) about PocketQuery.


Tags: confluence-server

server