我有以下的JSON:如何通過動態遍歷JSON數據將對象存儲在JSON數據中的某個級別?
{
"menu": [{
"name": "vegetation",
"id": "1",
"children": [
{
"name": "landuse",
"id": "1.1",
"children": [
{
"name": "forest area",
"id": "1.1.1",
"children": null
},
{
"name": "plantation",
"id": "1.1.2",
"children": null
}
]
}
]
}]
}
我要動態訪問的「孩子」的,其值是空的對象,並存儲在一個變量這些對象的「名字」。例如在這種情況下,無論是森林面積還是種植園。我如何使用JavaScript或jQuery來做到這一點?
你能否解釋一下你的意思是*動態訪問什麼*?你的意思是不管嵌套級別? – Taplar