Monday, March 1, 2010

Object Marshalling and Transients Fields

By default, the converters found in the grails.converters package only marshal persistent fields on domain objects. To override this behavior, use GroovyBeanMarshaller instead. It comes in 2 flavors, XML and JSON.

grails.converters.JSON.registerObjectMarshaller(Contact, {o, c ->
new org.codehaus.groovy.grails.web.converters.marshaller.json.GroovyBeanMarshaller().marshalObject(o, c)

No comments:

Post a Comment