有没有办法轻松指定是以深度还是浅度方式将对象转换为JSON?我知道您可以通过指定以下内容来配置Config.groovy文件中的grails.converters.JSON实用程序:
grails.converters.json.default.deep = true
Run Code Online (Sandbox Code Playgroud)
但是当我转换某些对象时,我不想深度转换.
我也看到有人推荐使用JSON.use("deep"),但是我收到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
看起来它可能是一个joda.time错误,但当我只使用简单的Config.groovy技术时,这不会发生.有点令人困惑......
任何帮助都会很棒!
| 归档时间: |
|
| 查看次数: |
2641 次 |
| 最近记录: |