[英]How to flatten nested array of JsonLists
[[{header=C, value=dsd}, {header=D, value=test}, {header=E, value=e}, {header=F, value=hhh}, {header=G, value=ghgh}]]
Above is an array of arrays of JsonLists and I need to flatten out the outer array to just be the inner array of JsonLists.上面是 JsonLists 的 arrays 数组,我需要将外部数组展平为 JsonLists 的内部数组。
I'd also eventually get only the values out of the JsonList and put those values into it's own separate array:我最终也只会从 JsonList 中获取值并将这些值放入它自己的单独数组中:
[dsd, test, e, hhh, ghgh]
It's basically similar to flattening an ArrayList of ArrayList.它基本上类似于展平 ArrayList 的 ArrayList。
final List<Map<String, Object>> result = jsonList.stream()
.flatMap(Collection::stream)
.collect(Collectors.toList());
and for the values和价值观
final List<Object> valueList = result.stream()
.map(i -> i.get("value"))
.collect(Collectors.toList());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.