【问题标题】:Is there any way to use JsonManagedReference and JsonBackReference in both directions?有什么方法可以双向使用 JsonManagedReference 和 JsonBackReference 吗?
【发布时间】:2018-04-15 06:25:04
【问题描述】:

我能够从子级序列化到父级(JsonManagedReference -> JsonBackReference),但它不适用于父级 -> 子级。

有什么办法吗?

我也尝试过使用 JsonIdentityInfo。在这里,我无法反序列化包含 2 个具有相同 ID 的对象的 Json。 我创建了一个问题:

Unable to deserialize JSON with same ID

【问题讨论】:

  • 一种选择是使用具有不同mixin的多个对象映射器,但我认为它很难阅读和维护,所以可能没有意义。

标签: java json spring-mvc jackson


【解决方案1】:

经过多次尝试,用@JsonIgnoreProperties 实现了双向遍历

示例:“@JsonIgnoreProperties(allowSetters = true, value = { "enterprise" })"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-27
    • 1970-01-01
    • 2021-11-15
    • 2020-04-23
    • 2016-09-20
    • 1970-01-01
    • 2016-11-07
    • 1970-01-01
    相关资源
    最近更新 更多