Jackson - How to specify a single implementation for interface-referenced deserialization?

前端 未结 3 757
感动是毒
感动是毒 2020-12-05 09:40

I want to deserialize a JSON-Object with Jackson. Because the target is an interface I need to specify which implementation should be used.

This information could be

3条回答
  •  渐次进展
    2020-12-05 10:11

    You can use @JsonDeserialize(as = ImplementationClass.class) on the interface as well and all references will be deserialized the same way.

    Note, if one of your Implementation classes is an enum, you might need @JsonFormat(shape = JsonFormat.Shape.OBJECT) on the enum as well.

提交回复
热议问题