Jackson deserializing nested polymorphic type

后端 未结 2 596
遥遥无期
遥遥无期 2020-12-19 22:20

I\'m trying to use Jakson to deserialize a nested polymorphic type. Meaning my top level type referes to another polymorphic type that finally is extended by class that\'s n

2条回答
  •  失恋的感觉
    2020-12-19 22:45

    Your definitions are messed up -- you are trying to use two type identifiers, type name AND class. This does not make any sense. You should choose one method or the other, not both.

    If you choose Java class name as type information, just leave out the name. Also, you only need to include @JsonTypeInfo for FirstLevel; sub-classes inherit this definition.

    If you prefer use of logical type name, drop the class property. You will also need to specify sub-type list, either with annotation, or by registering them via ObjectMapper.

提交回复
热议问题