Jackson JSON serialization, recursion avoidance by level defining

前端 未结 7 1322
庸人自扰
庸人自扰 2020-12-02 20:46

I use Jackson library for serialization of my pojo objects into JSON representation. For example I have class A and class B:

class A {
  privat         


        
7条回答
  •  既然无缘
    2020-12-02 21:15

    I recently encountered a similar problem: Jackson - serialization of entities with birectional relationships (avoiding cycles)

    So the solution is to upgrade to Jackson 2.0, and add to classes the following annotation:

    @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, 
                      property = "@id")
    public class SomeEntityClass ...
    

    This works perfectly.

提交回复
热议问题