groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ramesh Venkitaswaran <venkitaswa...@gmail.com>
Subject Removing hyphens from deeply nested Json keys
Date Thu, 10 Jan 2019 13:08:36 GMT
Hello
I’ve looked through the documentation and searched for an effective solution, but I’ve
been unsuccessful and hence my request for help.

I have an input json that’s nested, that is read via a JsonSlurper, and some of the keys
have hyphens in them. I need to replace those keys that have hyphens with underscores and
convert it back to json for downstream processing. I looked at the JsonGenerator.Options documentation
and I could not find any documentation for this specific requirement. 

I also looked through options to iterate through the Map that is produced from JsonSlurper,
but unfortunately I’m not able to find an effective solution that iterates through a nested
Map, changes the keys and produces another Map which could be converted to a Json string.

Any guidance on this would be greatly appreciated.

Thank you.
Mime
View raw message