Jackson deserialization … Unexpected token (END_OBJECT),

后端 未结 1 1305
情深已故
情深已故 2021-02-19 14:53

I am trying to deserialize a JSON array into a Java Collection using Jackson. This motivated by the answers to this question I asked last night Can I instantiate a superclass an

相关标签:
1条回答
  • 2021-02-19 15:33

    As often happens, writing out a question helps you see the solution. So I need to do two things.

    Firstly I need to add the type information into the JSON - which is not what I really wanted to do, but I guess you need to provide that information somewhere.

    And then I need to edit the annotation on QueryValue to be:

    @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")  
    @JsonSubTypes({  
        @Type(value = ResourceQueryValue.class, name = "ResourceQueryValue"),  
        @Type(value = NumericQueryValue.class, name= "NumericQueryValue")
        })  
    
    0 讨论(0)
提交回复
热议问题