I am using Jackson's @JsonIdentityInfo for removing circular objects from JSON.
Suppose following is Java Classes
Class A, B, C
and following is structure,
Class A{
     int id;
     B b;
     C c;
}
Class B{
     int id;
     C c;
}
My object is (A)
{
     id:1,
     b:{
          id: 2,
          c:{
            id: 3
            }
     },
     c: {
        id: 3
     }
}
It is changing object to
{
         id:1,
         b:{
              id: 2,
              c:{
                id: 3
                }
         },
         c: 3
    }
Because C has same id, I want this to be implemented as Breadth first i.e. first level should be remove object and give property but depth level should do this, is there a way to get it like following?
{
             id:1,
             b:{
                  id: 2,
                  c:3
             },
             c: {id:3}
        }
No, serialization proceeds depth-first, and changing that would require potentially buffering the whole output graph in memory before writing JSON.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With