I am struggling to what seems to be a trivial task. I need to iterate over this nested object...
[
{
"id": "1",
"name": "Level 1",
"parent": null,
"expanded": true,
"title": "Level 1",
"children": [
{
"id": "2",
"name": "Level 2",
"parent": 1,
"expanded": true,
"title": "Level 2",
"children": [
{
"id": "3",
"name": "Level 3",
"parent": 2,
"expanded": true,
"title": "Level 3"
}
]
}
]
}
]
... and end up with below structure.
I have tried .map(Object.values) but that only seems to work partially. What is the most optimal way to get there? What are the alternatives?
[
{ id: '1', name: 'Level 1', parent: null, expanded: true },
{ id: '2', name: 'Level 2', parent: 1, expanded: true },
{ id: '3', name: 'Level 3', parent: 2, expanded: true }
]
idandparentproperties do not match typewise.