I'm trying to transform my data on client side from this format:
[{
"id": 1,
"name": "dad",
"parent": [],
"children": [{
"group": {
"id": 2,
"name": "child1",
"parent": [{
"parent": 1
}]
}
},
{
"group": {
"id": 3,
"name": "child2",
"parent": [{
"parent": 1
}]
}
},
{
"group": {
"id": 8,
"name": "child3",
"parent": [{
"parent": 1
}]
}
}
]
}]
to this format:
[{
id: 1,
name: "parent",
parent: null,
children: [{
id: 2,
name: "child1",
parent: {
id: 1
},
children: []
},
{
id: 3,
name: "child2",
parent: {
id: 1
},
children: []
}
]
}]
key points:
- All keys should not be in a string type
- The 'parent' should just include the id of the parent
- 'group' object should be removed - and its contents should just replace him
I can't find a transformation library in npm to use and i need the data to be in that exact format to use in 'react-vertical-tree' component (didn't find any other good looking vertical tree component in react).