How do I convert an Object like this:
const data =
{
"1":{
name: 'Main Parent',
descendants: {
"1":{
name: "Main Child 1",
children: {
"1":{
name: "Sub Child 1"
}
}
},
"2":{
name: "Main Child 2",
children: {
"1":{
name: "Sub Child 1"
}
}
},
}
}
}
to remove the object keys then convert to array of objects like this:
const data = [
{
name: 'Main Parent 1',
descendants: [
{
name: "Main Child 1",
children: [
{
name: "Sub Child 1"
}
]
},
{
name: "Main Child 2",
children: [
{
name: "Sub Child 1"
}
]
}
]
}
]
Tried using lodash _.values() function and I can get the values of the objects but having trouble on doing it for nested objects . Any Ideas?