@JsonAppend virtual 属性 – ObjectReader 是否尊重它?

@JsonAppend virtual property – does ObjectReader honor it?

有文档介绍如何使用 @JsonAppend 在将 POJO 序列化为 JSON 时将虚拟 属性 添加到 POJO。但是,没有任何 Javadoc 或文章提到反序列化。假设我们给一个对象添加一个“schemaVersion”属性:

@JsonAppend(attrs = { @JsonAppend.Attr(value = "schemaVersion") })
public static class MixinWithVersion {}

我们如何读取设置了 属性 的对象?我得到 UnrecognizedPropertyException 并想知道是否有可能在添加了 属性.

的对象中回读

添加@JsonIgnoreProperties解决反序列化问题:

@JsonAppend(attrs = { @JsonAppend.Attr(value = "schemaVersion") })
@JsonIgnoreProperties({ "schemaVersion" })
public static class MixinWithVersion {}