I have a JSON tree of the form
{
"id":442500000904671234,
"reply":0,
"children":[
{
"id":442500532536893440,
"reply":1,
"children":[
{
"id":442500826561785856,
"reply":1,
"children":[
{
"id":442501277688545280,
"reply":1,
"children":[
{
"id":442501561940709376,
"reply":1,
"children":[
{
"id":442501884709199872,
"reply":1,
"children":[
]
}
]
}
]
}
]
}
]
},
{
"id":442500099315597312,
"reply":0,
"children":[
]
}
]
}
Now, I want to access all the childrens of the tree whose root node is 442500000904671234 from root to the leaf.
With the following python code, I am able to print the first level children
import json
f=open('tree.txt','r')
for line in f:
d=json.loads(line)
print len(d["children"])
for i in range (len(d["children"])):
print d["children"][i]["id"]
How to I get the all children of the tree?