has the following format
{
"2": {
"id": 2,
"name": "demo1",
"lv1": {
"4": {
"id": 20,
"name": "demo1-1",
"lv2": {
"2": {
"id": 2,
"name": "demo1-1-1"
},
"3": {
"id": 3,
"name": "demo1-1-2"
}
}
},
"7": {
"id": 23,
"name": "demo1-2"
}
}
},
"3": {
"id": 4,
"name": "demo2",
"lv1": {
"6": {
"id": 34,
"name": "demo2-1",
"lv2": {
"3": {
"id": 3,
"name": "demo2-1-1"
}
}
},
"8": {
"id": 55,
"name": "demo2-2"
}
}
}
}
needs to be converted to this format
[{
"value": "2",
"text": "demo1",
"children": [{
"value": "20",
"text": "demo1-1",
"children": [{
"value": "2",
"text": "demo1-1-1"
},
{
"value": "3",
"text": "demo1-1-2"
}
]
}]
},
{
"value": "4",
"text": "demo2",
"children": [{
"value": "34",
"text": "demo2-1",
"children": [{
"value": "3",
"text": "demo2-1-1"
}]
},
{
"value": "55",
"text": "demo2-2"
}
]
}
]
requires that the value of the new data corresponds to the id of the original data. The novice debugged it for a whole day without any effect. Seek Daniel"s solution.