I have the following data structure in Groovy
I want to know if Groovy offers a simple way (Preferably one-liner) to iterate through this data structure, find the TreeMap entry which has a key of "code" and apply the trim() function to it's value. As you can see in the image, the value the key "code" is "1880 ". I want to trim it and make it "1880". Thanks.
I tried this one and it worked for your data:
ageTypes = ageTypes.collect { it.each { it.value = (it.value instanceof String) ? it.value.trim() : it.value } }
UPD I believe it can be optimized somehow. But need to check how.