JAXB A cycle is detected in the object graph

后端 未结 4 822
说谎
说谎 2020-12-19 11:59

I want to convert my pojo to json with JAXB, my pojo have one to many relation, and when i convert my pojo to json, JAXB generate error \"A cycle is detected in the object g

4条回答
  •  盖世英雄少女心
    2020-12-19 12:27

    The JAXB specification requires that the property marked with @XmlID be a String property. MOXy impl allows to use long.

    One hack to keep using full JAXB compliant implementation would be to duplicate your id in a String field (before serialising)

    Don't know so much about JAXB but XStream makes you able to use different modes and some of these modes will give references to the xpath address (absolute or relative) of an element in your xml, if these elements are already displayed. (And you can do Json with XStream)

提交回复
热议问题