Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am having an issue on how to iterate through a json file with a recursive field to populate a table. Let us say I have a json file of the structure as followed:
{
"firstName": "John",
"address" : "1 Main St",
"children" : [
{ "firstName" : "James",
"address": "3 Commercial St",
"children": [
{
"firstName": "Sara",
"address": "4 Hunt Drive"
},
{
"firstName": "Sam",
"address": "here3"
}
]
}
]
}
The json objects contain the fields "firstName", "address" and sometimes the list "children", which contains objects of the same schema, hence a recursive loop.
I wish to create a table that has "firstName" and "address" as columns and each row will correspond to one json object. Simply specifying the json query '$..firstName' for example enters all of the instances of 'firstName' as one row - I do not know how to get each as its own row, which requires a recursive json loop to all levels where children lists are present.
Hello @mattg1221
Can you give an example of what you want to have as a result from one of your json? This will allow me to know how to implement this recursive loop in question.
Best regards
It would be a table with two columns like the following:
|firstName | Address|
John 1 main st
James 3 Comm St
Sara 4 Hunt Drive
Hello @mattg1221
I found an algo (job design) below that will allow you to parse your json recursively.
1)
2)
3)
4)
5)
Best Regards