i have the following array of dictionaries with the one below as an example of a single dictionary
{
"id": 80,
"name": "Low Level Topic",
"questions": [
{
"id": 23,
"shortName": null,
"name": "Some question"
},
{
"id": 24,
"shortName": null,
"name": "Some question 2"
}
],
"parentTopic": {
"id": 10,
"name": "Higher Level Topic",
"parentTopic": {
"id": 1,
"name": "Top Level Topic",
"parentTopic": null
}
}
}
}
and i would like to reverse the tree to end up with the following
{
"id": 1,
"name": "Top Level Topic",
"childTopic": {
"id": 10,
"name": "Higher Level Topic",
"childTopic": {
"id": 80,
"name": "Low Level Topic",
"questions": [
{
"id": 23,
"shortName": null,
"name": "Some question"
},
{
"id": 24,
"shortName": null,
"name": "Some question 2"
}
],
}
}
}
i have been trying to find an easy way to regenerate/restructure the data, but was not successful. I would appreciate if anyone could help