【发布时间】:2019-04-07 14:27:34
【问题描述】:
使用 Groovy,要求是收集地图的嵌套元素值及其顶级元素值。
不确定是否需要递归方法。
示例 JSON
{
"items": [
{
"attribute": "Type",
"options":
[
{
"label": "Type1",
"value": "1"
},
{
"label": "Type2",
"value": "2"
}
]
},
{
"attribute": "Size",
"options": [
{
"label": "SizeA",
"value": "A"
},
{
"label": "SizeB",
"value": "B"
}
]
}
]
}
收集后的预期输出
[
{attribute=Type,label=Type1,value=1},
{attribute=Type,label=Type2,value=2},
{attribute=Size,label=SizeA,value=A},
{attribute=Size,label=SizeB,value=B}
]
【问题讨论】:
标签: json groovy nested collect