Categories
Mastering Development

Groovy – Merge/Group By List of Maps

I have a list of maps that follows the structure List<Map<String,List<String>>> List<Map<String,List<String>>> lstData = [] lstData << ["Year":["FY19"],"Period":["Oct"],"Account":["A1000","A1001"]] lstData << ["Year":["FY19"],"Period":["Oct"],"Account":["A1001","A1002"]] lstData << ["Year":["FY19"],"Period":["Nov"],"Account":["A1000","A1001","A1002"]] lstData << ["Year":["FY19"],"Period":["Dec"],"Account":["A1000","A1002"]] lstData << ["Year":["FY20"],"Period":["Jan"],"Account":["A1000","A1003"]] I have been trying to build something that would output a list in a similar structure as the input, but merged: List<Map<String,List<String>>> lstTarget = [] […]