我有这个输出。它来自这种类型 List<List<TextValue>>
textvalue类是string text,string value。
"data": [
[
{
"text": "DescCode",
"value": "01"
},
{
"text": "DescName",
"value": "Description 1"
},
{
"text": "SecondCode",
"value": "01"
}
],
[
{
"text": "DescCode",
"value": "02"
},
{
"text": "DescName",
"value": "Description 2"
},
{
"text": "SecondCode",
"value": "02"
}
]
]
我想把它转换成这个json输出。我相信这就是这个物体的构造。 List<Map<String, String>>
```
"data": [
{
"DescCode": "01",
"DescName": "Description 1",
"SecondCode": "01"
},
{
"DescCode":"02",
"DescName":"Description 2",
"SecondCode":"02"
}
]
我的json是由我的spring rest控制器自动创建的,所以我只需要java对象,json仅供参考。我是不是有点不对劲? `List<Map<String, String>>`
2条答案
按热度按时间0aydgbwb1#
下面是嵌套的
TextValue
物体。这基本上是流式处理内部列表,然后流式处理每个列表,以创建具有指定键和值的Map。然后将Map收集到一个列表中。
印刷品
textvalue类。
rn0zuynd2#
我想出来了。正在加载我的
List<Map<String, String>>
数据类型是anwser。我想我需要使用一些花哨的流处理,但那不是必须的。嵌套循环和正确的对象把我带到了那里。