Nested json into table

Hi,

I am working on transformer snippet to return nested json to a table. I am stuck at a step, where there is nested json within a nested json and I would like to get those all into columns: "title", "Status", "Priority" etc should all be seperate columns and the corresponding text as its value. Would highly appreciate any suggestions

Hi @sri555,

I'm not sure I understand the structure of your json, but I'm sure you're able to use {{item}} in the mapped value of your columns to map each value for each column.

This recent post may be helpful as an example.

If this doesn't work, it would be helpful if you could provide an dummy example of your json (or provide a picture of your data source state) to see the structure.

Hope this helps

Hi Miguel,

Thanks for your inputs.. Doesn't seem work - I tried {{items.Subitems}} , but i think there is the column to be included as well? I tried this {{items.column.Subitems}} not sure if this is correct - doesnt seem to work

In regards to datasource, this is a graphql query of monday.com and the raw output looks something like this


I then used transformer to get this format


Hello!

If you are looking to get all of the All columns to appear with the name, I think you are going to need to pull the All object array out in your transformer and iterate through that to build the remaining columns into your return object.

If you are dealing with dynamic column values this might be the best way. If it is a fixed set of columns that you know the name of you could just build them into the object transformer directly by name.

Another approach could be to use a List View with the data from the All object being used to populate a table component for each item with the data source being something like:

{{transformer1.value.all}}

table view is the preferred option - I did try this {{transformer1.value.all}} already and got returned an empty table.

"I think you are going to need to pull the All object array out in your transformer and iterate through that to build the remaining columns into your return object" - Any suggestions of how to do this? This is the step I am stuck at

From what I can see in your screenshots, you likely need to parse the JSON data in the All object with JSON.parse(transformer1.value.all) to get the usable data from within.

As for the iteration path, you can parse that JSON and loop through the array when building the newObj with a mapping function like:

JSON.parse(data[key]['column_values']).map(column => newObj[column.title] = column.text)

YMMV since I didn't really test around with the same object data you have from your Graph query.

I tried something else and seems to work: new_obj['Subitems'] = data[key]['column_values'][0]['text'].

1 Like