我使用Jackson库将我的pojo对象序列化为JSON
表示.例如,我有A类和B类:
class A {
private int id;
private B b;
constructors...
getters and setters
}
class B {
private int ind;
private A a;
constructors...
getters and setters
}
Run Code Online (Sandbox Code Playgroud)
如果我想序列化来自A类的对象,则在序列化时有可能获得递归.我知道我可以通过使用来阻止它@JsonIgnore
.
是否可以按深度级别限制序列化?
例如,如果级别为2,则序列化将采用以下方式:
提前致谢.