I would like to get the path of all the keys of a nested dict in a list. For example if my dict looks like below
{
"persons": [{
"id": "f4d322fa8f552",
"address": {
"building": "710",
"coord": "[123, 465]",
"street": "Avenue Road",
"zipcode": "12345"
},
"cuisine": "Chinese",
"grades": [{
"date": "2013-03-03T00:00:00.000Z",
"grade": "B",
"score": {
"x": 3,
"y": 2
}
}, {
"date": "2012-11-23T00:00:00.000Z",
"grade": "C",
"score": {
"x": 1,
"y": 22
}
}],
"name": "Shash"
}]
}
I would like to get the path like
path = [['persons'], ['persons','id'],['persons','address'],['persons','address','building']...]
up to the last key.
I tried to traverse the entire dict to append the path variable. tried to get some inspiration from Print complete key path for all the values of a python nested dictionary but I am unable to get the paths which are inside list.
Are there any other possible ways to get to this.