Is there a way to easily specify whether to convert an object as JSON in a deep or shallow manner? I know you can configure the grails.converters.JSON utility in the Config.groovy file by specifying something like the following:
grails.converters.json.default.deep = true
but when I convert certain objects, I don’t want to deep convert.
I also saw that somebody recommended using JSON.use(“deep”), but I get the following error:
Error 2012-03-04 00:39:13,673 ["http-bio-8080"-exec-1] ERROR errors.GrailsExceptionResolver - IllegalAccessException occurred when processing request: [GET] /Quaffic/home/json
Class org.codehaus.groovy.grails.web.converters.marshaller.json.GenericJavaBeanMarshaller can not access a member of class org.joda.time.tz.DateTimeZoneBuilder$PrecalculatedZone with modifiers "public". Stacktrace follows:
Message: Class org.codehaus.groovy.grails.web.converters.marshaller.json.GenericJavaBeanMarshaller can not access a member of class org.joda.time.tz.DateTimeZoneBuilder$PrecalculatedZone with modifiers "public"
Line | Method
->> 198 | value in grails.converters.JSON
It seems like it could be a joda.time error, but this doesn’t happen when I just use the plain Config.groovy technique. Kind of confusing…
Any help would be great!
My solution was to not rely on deep/shallow json generation. I created a map, inserted elements, and serialized that. Probably not the best practice, but it gets the job done.