Displaying nested JSON in a table

Hi! I'm entirely new to this...and have hit a problem with the very first thing I've tried. I'm querying for some JSON (see below) via an API, which is returning what I'm asking for OK. However, when I view it within a table, it's putting the entire content of the returned line within a single column called 'GAZETTEER_ENTRY'. I can see why it's doing this, but how do I tell it that I really want 'ID', 'Name' and 'Type' to be the three separate column headers? Can I change the code in the Data block to request this? It's currently set at {{ myquery.data.results}}, but adding '.GAZETTEER_ENTRY' to the end of that string (which was my guess at solving it) didn't seem to work. Any ideas, please?

Guy

{
"header": {
"query": "Glasgow",
"format": "JSON",
"totalresults": 1
},
"results": [
{
"GAZETTEER_ENTRY": {
"ID": "12345",
"NAME": "Glasgow",
"TYPE": "populatedPlace"
}
}
]
}

I took your JSON and added it to a temp state as a test and then used a table component and added the value as [{{state2.value.results['0'].GAZETTEER_ENTRY}}]. Note here that I put [ and ] around that to make it an array...

1 Like

Ah, many thanks for that! It's now working for me at this end, also. Cheers.

Guy

@GuyHeathcote - happy to help
If you are running a query or an API that pulls that data in you can just take that resource name and replace "state2" so you don't have to use the temp state and populate the table directly....please mark as solution above so other people can find it. Best of luck

1 Like