0
我想從一個json的關鍵名是「label」並且想要存儲在一個列表中獲取所有的值。 我的問題是,標籤鍵的位置不固定。有時它在子節點下有時在父節點下,有時在子節點下到子節點。我們可以在常規中使用遞歸閉包,但我不知道如何?groovy json中的遞歸閉包
的Json ::
[
{
{
"id": "2",
"label": "NameWhatever"
},
{
"id": "123",
"name": "Some Parent Element",
"children": [{
"id": "123123",
"label": "NameWhatever"
},
{
"id": "123123123",
"name": "Element with Additional Children",
"children": [{
"id": "123123123",
"label": "WhateverChildName"
},
{
"id": "12112",
"name": "Element with Additional Children",
"children": [{
"id": "123123123",
"label": "WhateverChildName"
},
{
"id": "12112",
"name": "Element with Additional Children",
"children": [{
"id": "12318123",
"label": "WhateverChildName"
},
{
"id": "12112",
"label": "NameToMap"
}
]
}
]
}
]
}
]
}
]