Find the path of JSON for a key value
jSon = {
"id":"node1",
"name":"Languages",
"rel":"",
"children":1,
"step":1,
"path":1,
"nodes":[
{
"id":"node2",
"name":"Java",
"rel":"Pure Object Oriented Prog",
"children":1,
"step":2,
"path":2,
"nodes":[
{
"id":"node3",
"name":"C#",
"rel":"Framework",
"children":0,
"step":3,
"path":3,
"nodes":[]
},{
"id":"node4",
"name":"C++",
"rel":"OOPS",
"children":0,
"step":3,
"path":4,
"nodes":[]
}]
}]
};
For above structure, how do I get path of id(key) = node3(value)
(i.e) jSon.nodes[0].nodes[1].id
So that i could able push new Object (i.e) jSon.nodes[0].nodes.push(newjSon);
Or is there any other way to add new object in particular position for
this structure... Please suggest some javascript code.. No jQuery
No comments:
Post a Comment