Hello, I have JSON file which look like this
[
{
"customer": "A",
"children": [
{
"id": "1",
"name": "B"
},
{
"customer": "B",
"children": []
},
{
"customer": "C",
"children": [
{
"id": "4",
"name": "E"
}
]
},
{
"customer": "E",
"children": [
{
"id": "5",
"name": "F"
}
]
},
{
"customer": "D",
"children": []
}
]
}
]
and I need my output to be like this, How can I do this using JavaScript
[
{
"customer": "A",
"children": [
{
"customer": "B"
},
{
"customer": "C",
"children": [
{
"customer": "E",
"children": [
{
"customer": "F"
}
]
}
]
},
{
"customer": "D"
}
]
}
]
Top comments (0)