This is my nested map, I want to iterate over each "myMap":
def myMaps = [
"myMap1": [
"prop1": 'sdfsdfdsf',
"prop2": 'dsdfsdfs',
"prop3": 'sdfsdfsdf'
],
"myMap2": [
"prop1": 'sdfsdfdsf',
"prop2": 'dsdfsdfs',
"prop3": 'sdfsdfsdf'
]
"myMap3": [
"prop1": 'sdfsdfdsf',
"prop2": 'dsdfsdfs',
"prop3": 'sdfsdfsdf'
]
"myMap4": [
"prop1": 'sdfsdfdsf',
"prop2": 'dsdfsdfs',
"prop3": 'sdfsdfsdf'
]
]
I tried this several ways but it's not iterating over the maps, it's still treating it like a single item:
myMaps.each() {
println '========'
it.dump()
}
for (item in myMaps) {
println '========'
println item.key
}
Edit
This was the only way I could manage to do this but I don't understand why. Is this also possible with a more traditional foreach style loop?
myMaps.each {
key, value ->
println key
println value
}