Jackson@jsonidentityinfo更改原始数据结构

Jackson@jsonidentityinfo更改原始数据结构,json,jackson,circular-reference,jsonidentityinfo,Json,Jackson,Circular Reference,Jsonidentityinfo,我有下面两个循环引用的类,为了方便起见,我没有设置getter和setter @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "i") public class A{ int i; B b1; B b2; } @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.clas

我有下面两个循环引用的类,为了方便起见,我没有设置getter和setter

@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "i")
public class A{
    int i;
    B b1;
    B b2;
}

@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "i")
public class B {
    int i;
    AI a;
}
如果A.b1和A.b2引用同一个B对象,我得到的序列化json如下:

 {
  "i": 1,
  "b1": {
    "i": 2,
    "a": 1
  },
  "b2": 2
}
但我的预期结果是:

 {
  "i": 1,
  "b1": {
    "i": 2,
    "a": 1
  },
  "b2": {
    "i": 2,
    "a": 1
  }
}
我检查了jackson的源代码,它看起来像以前使用过的对象的jackson store id/引用,如果任何其他对象使用相同的引用,它将使用id而不是序列化整个对象,如果对象保持在同一个循环链中,这是好的,但如果它们不保持在同一个链中,那么它会像我的示例所示的那样奇怪


任何人都可以通过@identityinfo注释帮助获得我的预期结果

运气好吗?