Reputation: 13
I am building an app with Groovy/Grails (long-time Java developer), and have had some difficulty with making the JSON renderer do what I want. I would like to change the default name rendering scheme to snake case instead of camel case.
The controller code is very simple right now:
Fund show(String id) {
respond fundService.getFund(id)
}
With Java I would use Jackson and a custom naming strategy, like so:
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
Any help would be appreciated! If there is no way of doing this, and I just need to switch out the renderer wholesale, I would welcome knowing that as well. Thank you.
Upvotes: 1
Views: 329
Reputation: 191
Create a custom marshaller - you can control anything from there
see here how to create one:
http://compiledammit.com/2012/08/16/custom-json-marshalling-in-grails-done-right/
Upvotes: 1