从groovy中的地图列表中获取值的最佳方法

时间:2017-09-27 06:55:07

标签: groovy

def jobsInView = [
   ["name":"hello", "age":"45","language":"english"],
   ["name":"hi", "age":"22","language":"english"],
   ["name":"ravi", "age":"22","language":"spanish"] 
]

我需要获取密钥的值" name"在列表中,如下所示:

def listOfNames = ["hello","hi","ravi"]

请告诉我获取上述值的最佳方法。

1 个答案:

答案 0 :(得分:3)

尝试使用spread operator

def names = jobsInView*.name