Greetings, I'm relatively new to the concept of recursion and it has been some time since I last worked with it, so please forgive me if my question appears a bit basic. Essentially, I have a JSON structure similar to this:
{
"id": "1111",
"name": "Outdoor Skiing",
"parent_id": "1110",
"parents": [
{
"id": "1000000",
"name": "Movies"
},
{
"id": "1000001",
"name": "Outdoor Movies"
}
]
}
I am looking to reorganize it into the following format:
{
"id":"1000000",
"name":"Movies",
"children":[
{
"id":"1000001",
"name":"Outdoor Movies",
"children":[
{
"id":"1111",
"name":"Outdoor Skiing",
"parent_id":"1110",
"parents: [....these can stay here....]
}
]
}
]
}
Would greatly appreciate any assistance on how to achieve this using recursion. Thank you!