我的樣品JSON,我想通過刪除重建以下JSON「孩子:」對象如何使用JavaScript來重新嵌套JSON和重組
{
"Child":{
"DeviceList":[
{
"Child":null,
"DeviceId":"7405618",
"Signal":"-90"
},
{
"Child":{
"DeviceList":[
{
"Child":{
"DeviceList":[
{
"Child":null,
"DeviceId":"3276847",
"Signal":"-86"
}
]
},
"DeviceId":"2293808",
"Signal":""
}
]
},
"DeviceId":"4915247",
"Signal":"-90"
}
]
}
}
新的結構應該是這樣的
{
"DeviceList":[
{
"DeviceList":null,
"DeviceId":"7405618",
"Signal":"-90"
},
{
"DeviceList":[
{
"DeviceList":[
{
"DeviceList":null,
"DeviceId":"3276847",
"Signal":"-86"
}
],
"DeviceId":"2293808",
"Signal":""
}
],
"DeviceId":"4915247",
"Signal":"-90"
}
],
"DeviceId":"4915247",
"Signal":"-90"
}
我正在尋找一個嵌套的遞歸解決方案,用於動態json樹結構,其中我的JSON內容看起來像提供的示例。
? –