Custom string formatting in Grails JSON marshaller
- by ethaler
I am looking for a way to do some string formatting through Grails JSON conversion, similar to custom formatting dates, which I found in this post.
Something like this:
import grails.converters.JSON;
class BootStrap {
def init = { servletContext ->
JSON.registerObjectMarshaller(String) {
return it?.trim() }
}
def destroy = {
}
}
I know custom formatting can be done on a per domain class basis, but I am looking for a more global solution.