Cannot with (de)serialize a List with polymorphic items in Jackson

后端 未结 1 573
不思量自难忘°
不思量自难忘° 2021-01-11 21:03

I have an issue (de)serializing JSON that is not defined by me.

Here is some code and JSON that explains the issue:

Code:

public static clas         


        
相关标签:
1条回答
  • 2021-01-11 21:11

    There is no way to map JSON you show automatically; it is not one of 4 types supported by Jackson.

    If you can't make server produce more standard structure (for which automatic support exists), you will need to write a custom deserializer; or to do data-binding in two steps, first into an intermediate easily mappable structure (like JsonNode or Map) and then from that into desired structure manually extracting type, using that (for example, with ObjectMapper.convertValue(object, resultType).

    0 讨论(0)
提交回复
热议问题