4

I have two model:

Parent:
id     name       childrenIds
1      parent1    1,2
2      parent2    3

Child
id     parentId
1      1
2      1
3      2

When I am trying to serialize this models using Jackson, stack overflow error occurred.

I am try to resolve my problem using mentioned solution in this question: Infinite Recursion with Jackson JSON and Hibernate JPA issue

  • But when I am using @JsonIgnore I can't access child or parent node at all.
  • When I am using @JsonManagedReference and @JsonBackReference annotations, only one way serialization is possible. means that if childrenIds in parent marked as JsonManagedReference , serializing a child object does not contain parent
  • With using @JsonIdentityInfo , every object only serialized one time. means that after serialization children[0].parent has value but children1.parent is undefined, because parnt1 is serialized one time

How can I serialize an object using jackson, with complete bidirectional access

Community
  • 1
  • 1
Nik Kashi
  • 4,447
  • 3
  • 40
  • 63

0 Answers0