使用@JsonIdentityInfo时如何禁用对象引用?

How to disable object reference when using @JsonIdentityInfo?

提问人:howie 提问时间:7/17/2013 最后编辑:Daniele Licitrahowie 更新时间:6/9/2019 访问量:1163

问:

当我使用 时,例如JsonIdentityInfo

@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@dataSet")

Jackson 将替换对象,该对象已显示为 id ,如下所示。

{
  "@dataSet" : 1,
  "createdDate" : 1374039391476,
  "lastUpdated" : 1374039391476,
  "dataSetId" : 1,
  "dataSetVersions" : [ {
    "createdDate" : 1374039391486,
    "lastUpdated" : 1374039391486,
    "dataSetVersionId" : null,
    "dataSetVersionNumber" : 1,
    "startTime" : null,
    "endTime" : null,
    "dataSet" : 1 <------ 1 reference to "@dataSetId":1
}

我也试过了@JsonIdentityReference(alwaysAsId = true)

此注解强制对象替换为 id,但我想禁用替换

我可以禁用此功能而不替换为 id 吗?

JSON 杰克逊

评论

0赞 Chetan Joshi 11/12/2019
请查看 logicbig.com/tutorials/misc/jackson/...此页面将对您有所帮助。
0赞 slindenau 6/28/2022
预期结果是什么?需要按 ID 进行此映射才能将背面连接到 .当您再次反序列化此 json 时,它会将 ID 替换为实际对象引用。dataSetVersiondataSet

答: 暂无答案