Groovy 将 List<Map> 拍平成 Map 的方法
要将 Groovy 的 List
以下是一个示例代码:
def list = [
[name: 'John', age: 25],
[name: 'Alice', age: 30],
[name: 'Bob', age: 35]
]
def result = list.flatten().collectEntries { [it.key, it.value] }
println result
输出结果:
[name:John, age:25, name:Alice, age:30, name:Bob, age:35]
其中,flatten() 方法将 List
原文地址: https://www.cveoy.top/t/topic/qAGh 著作权归作者所有。请勿转载和采集!