Jackson custom deserializer for one field with polymorphic types

前端 未结 1 835
暖寄归人
暖寄归人 2021-02-05 03:57

Update:

I tried to debug in jackson source code and find out that in the method

deserialize(JsonParser jp, DeserializationContext ctxt) of

相关标签:
1条回答
  • 2021-02-05 04:05

    Jackson processes @JsonTypeInfo before choosing which Deserializer to use, probably because the choice of Deserializer could depend generally on the type. However, you can easily disable this on a per-field basis the same way you specify custom Deserializer - by annotating the field directly:

    @JsonDeserialize(using = DefinitionDeserializer.class)
    @JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
    private Definition definition;
    
    0 讨论(0)
提交回复
热议问题