I have the following array of objects.. How can I flatten a multi-dimensional array of objects into a single dimensional array of objects?
[{
"name":"Locations",
"children":[
{
"name":"U.S."
},
{
"name":"Canada"
},
{
"name":"London"
}
]
},{
"name":"Benefits",
"children":[
{
"name":"U.S. Benefits",
"children":[
{
"name":"U.S. Benefits at a Glance"
},
{
"name":"U.S. Holiday Calendar"
}
]
},
{
"name":"London Benefits",
"children":[
{
"name":"London Benefits at a Glance"
},
{
"name":"London Holiday Calendar"
}
]
},
{
"name":"India Benefits",
"children":[
{
"name":"India Benefits at a Glance"
},
{
"name":"India Holiday Calendar"
}
]
}
]
}]
I need all the children to be in the same level as their parents in a single dimensional array.Any help will be appreciated.