【发布时间】:2012-10-02 12:37:13
【问题描述】:
一直在使用 IDMLlib 将 IDML 文件加载到 POJO,但是当我尝试使用 Jackson JSON 将生成的 java 对象序列化为 JSON 时,我一直遇到无限递归的麻烦。
Caused by JsonMappingException: Infinite recursion (StackOverflowError)
(through reference chain:
de.fhcon.idmllib.api.elements.preferences.Preferences["layoutAdjustmentPreference"]
->de.fhcon.idmllib.api.elements.preferences.LayoutAdjustmentPreference["parent"]
... etc
->> 539 | serializeFields in com.fasterxml.jackson.databind.ser.std.BeanSerializerBase
在解析过程中多次发生这种情况。
Idml.document -> Document.root -> Idml.document -> Document.root 是类似的。
我正在使用 Jackson 的 ObjectMapper 将 POJO 转换为 JSON:
Idml idml = new Idml("test.idml");
ObjectMapper mapper = new ObjectMapper();
String JSONstring = mapper.writeValueAsString(idml);
IDMLlib 类已编译,因此我无法对它们进行任何更改。
任何人都知道我仍然可以使用 IDMLlib 返回的 java 对象而无需创建自己的方法吗?
编辑:
似乎在整个过程中都提到了“根”和“父”。所以基本上我要问的是是否有人知道如何能够在不修改对象的情况下序列化它
【问题讨论】:
-
重试,得到了前面提到的document->root问题。但是,主要问题仍然相同。失败:com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError)(通过引用链:de.fhcon.idmllib.api.elements.Document["root"]->de.fhcon.idmllib.api.elements。 idml["document"]-> de.fhcon.idmllib.api.elements.Document["root"]->...等
-
自始至终似乎都提到了“root”和“parent”。所以基本上我要问的是是否有人知道如何能够在不修改对象的情况下序列化它。