Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 禁用某些序列化效率_Json_Serialization_Spring Boot_Jackson - Fatal编程技术网

Json 禁用某些序列化效率

Json 禁用某些序列化效率,json,serialization,spring-boot,jackson,Json,Serialization,Spring Boot,Jackson,我有一个实体,它有四个映射到同一实体的@OneToOne: @Entity @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", scope = TaxTable.class) public class TaxTable extends BaseEntity { @OneToOne( fetch = FetchType.LAZY) @JsonView(

我有一个实体,它有四个映射到同一实体的
@OneToOne

@Entity
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", scope = TaxTable.class)
public class TaxTable extends BaseEntity {

    @OneToOne( fetch = FetchType.LAZY)
    @JsonView({Views.Summary.class, Views.Detailed.class})
    private TaxRate taxRate1;

    @OneToOne(fetch = FetchType.LAZY)
    @JsonView({Views.Summary.class, Views.Detailed.class})
    private TaxRate taxRate2;

    @OneToOne(fetch = FetchType.LAZY)
    @JsonView({Views.Summary.class, Views.Detailed.class})
    private TaxRate taxRate3;

    @OneToOne(fetch = FetchType.LAZY)
    @JsonView({Views.Summary.class, Views.Detailed.class})
    private TaxRate taxRate4;
}
当我从控制器中检索TaxTable时,我得到以下信息:

{
  "id": 1,
  "taxRate1": {
    "id": 1,
    // more properties here
  },
  "taxRate2": 1,
  "taxRate3": 1,
  "taxRate4": 1
}

这是因为它们都引用同一个对象。但是有没有办法告诉杰克逊不要这么有效率?我看了一遍,但找不到任何具体的信息。

“告诉杰克逊不要这么有效率”。你能详细解释一下这句话吗?我希望taxRate1-4都有完整的TaxRate对象。正如我在问题中所说,因为它们都是同一个物体,杰克逊只给了我一次完整的物体。这通常是有帮助的,但在我当前的用例中,我不希望发生这种情况。