java - Cannot deserialize JSON with missing polymorphic field -


i have class follows

class xyz {     private string type;      private typespecific typespecific;      public typespecific gettypespecific() {         return typespecific;     }      @jsontypeinfo(         use = jsontypeinfo.id.name,          include = jsontypeinfo.as.external_property,          property = "type"                    )     @jsonsubtypes({              @jsonsubtypes.type(value = atypespecific.class, name = "a")     })     public void settypespecific(typespecific typespecific) {        this.typespecific = typespecific;     } } 

class atypespecific extends typespecific.

i want deserialize json {"type":"b"} typespecific set null in object. getting following exception:

com.fasterxml.jackson.databind.jsonmappingexception: missing property 'typespecific' external type id 'type'

how deserialize above mentioned json object?

dependency versions:

jackson-annotations: 2.7.0, jackson-core: 2.7.4, jackson-databind: 2.7.4

i have tried latest patch, i.e. 2.7.9 , latest version 2.8.6. not working. please let me know if possible. in advance.

you need set following property make run:

// version 1.x        mapper.configure(deserializationconfig.feature.fail_on_unknown_properties, false); // newer versions mapper.configure(deserializationfeature.fail_on_unknown_properties, false)  

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -