What I currently have is list of maps
[{"title":"Witcher","desc":"456"},{"title":"Harry Potter","desc":123},{"title":"ozark","desc":"879"}]
I want to end up with is a list of titles.
["Witcher","Harry Potter","ozark"]
My current code somewhat like this
ListMap.stream().filter({ map -> map.containsKey("Title") }).collect(Collectors.toList())
CodePudding user response:
Hope this will help:
def map = [["title":"Witcher","desc":"456"],["title":"Harry Potter","desc":123],["title":"ozark","desc":"879"]]
def names = map.collect{entry -> entry.title}
println(names)