I'm working on json Data with inner childrens. i need to get all the name's in the json.
json data
this.res = [
{
"children": [
{
"children": [
{
"children": [],
"name": "P Sub Child 3",
},
{
"children": [
{
"children":[],
"name" : "data"
}
],
"name": "PSubChild2",
}
],
"name": "PChild1",
},
{
"children": [
{
"children": [],
"name": "PSubChild3",
}
],
"name": "PChild2",
}
],
"name": "Parent1",
},
{
"children": [],
"name": "Parent2",
}
];
in my application names of every child has to store in the variables using angular2. Data is dynamic changes as per the user in my application
MyNodewhich has children nodes (Array<MyNodeNode> childen) and a name attrbute (nodeName:string). Then you can create a method that recursively find all the names in your data-object.