I use Groovy a lot. It’s simple and easy to use, runs on JVM and saves me from Java verbosity. I also like the fact that it’s dynamic.
I do convert the maps into JSON when returning results to a browser. I don’t use anything fancy, just a couple lines of Groovy code to do that.
With this code there is quite a bit of assumptions though:
- it will only work for Map
- it assumes Strings are used as Map Keys
- it will convert Maps, Lists and Objects
- when it meets Object it will call .toString() on it to get it’s value
- it will try to format it with tabs and new lines a bit, so it’s more pleasant for the eye and human readable
Hope it would be useful for you. Greg