I want to recurse the following nested json string in python.
{
"hierarchy": {
"record": {
"id": 1,
"record": [
{
"id": 2,
"record": [
{
"id": 3,
"record": [
{
"id": 4,
"record": []
},
{
"id": 5,
"record": []
}
]
}
]
},
{
"id": 6,
"record": [
{
"id": 7
}
]
}
]
}
},
"type": "record"
}
and get flattened result as follows.
record_field id parent_id
=============================
record 1 null
record 2 1
record 3 2
record 4 3
record 5 3
record 6 1
record 7 6
I am using recursive function but not yet successful to get that expected result. Any help of solution would be great.