How avoid infinite loop during Json Serialization in Java

后端 未结 1 1916
刺人心
刺人心 2021-01-25 13:43

I retrieve a list of Brothers using hibernate

public class Brother {
    public int brotherId;
    public string name;

    public List brothers;
         


        
1条回答
  •  时光说笑
    2021-01-25 14:27

    Issue is arising because of Circular Reference.

    Since Jackson 1.6 you can use two annotations to solve the infinite recursion problem without ignoring the getters/setters during serialization: @JsonManagedReference and @JsonBackReference.

    refer here for more

    0 讨论(0)
提交回复
热议问题