i ve a json object as below.
[{
"data":{
"title":"Root"
},
"attr":{
"id":1,
"parentId":0
},
"state":"open",
"children":[{
"data":{
"title":"Stem"
},
"attr":{
"id":11,
"parentId":1
},
"state":"open",
"children":[{
"data":{
"title":"Branch 1"
},
"attr":{
"id":111,
"parentId":11
},
"state":"open",
"children":[{
"data":{
"title":"Sub Branch 1"
},
"attr":{
"id":1111,
"parentId":111
},
"state":"open",
"children":[{
"data":{
"title":"Leaf"
},
"attr":{
"id":111111,
"parentId":111
}
}]
},
{
"data":{
"title":"Sub Branch 2"
},
"attr":{
"id":111111,
"parentId":111
}
}
]
},
{
"data":{
"title":"Branch 2"
},
"attr":{
"id":119,
"parentId":11
},
"state":"open",
"children":[{
"data":{
"title":"Sub branch"
},
"attr":{
"id":120,
"parentId":119
}
}
]
}
]
}
]
}]
basically the structure would look like this
i ve the ID of all the nodes in attributes (attr). when an ID of any node is given, i want to get the json of that node and its children.
For eg. with a given ID say 111, the json for this and its children would be
{
"data":{
"title":"Branch 1"
},
"attr":{
"id":111,
"parentId":11
},
"state":"open",
"children":[{
"data":{
"title":"Sub Branch 1"
},
"attr":{
"id":1111,
"parentId":111
},
"state":"open",
"children":[{
"data":{
"title":"Leaf"
},
"attr":{
"id":111111,
"parentId":111
}
}]
},
{
"data":{
"title":"Sub Branch 2"
},
"attr":{
"id":111111,
"parentId":111
}
}
]
}
i want to get this json when i enter the id 111. how do i do it??
EDIT:Consider i have a GUI to enter the ID of node. and say I enter 111 i should be able to get the json as above. i just need how to do it in js or jQuery. I dont care about UI.
Thanks.!