Skip to content

Polymorphic deserialization should handle case-insensitive Type Id property name if MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES is enabled #1983

@soundvibe

Description

@soundvibe

Consider this data class:

@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "operation")
@JsonSubTypes({
        @JsonSubTypes.Type(value = Equal.class, name = "eq"),
        @JsonSubTypes.Type(value = NotEqual.class, name = "noteq"),
})
public abstract class Filter {
    public String operation;
}

MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES is enabled for ObjectMapper:
objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);

Trying to deserialize json { "operation": "EQ"} fails with:
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'eq' into a subtype of...

but deserializing from { "operation": "eq" } works as expected.

It would be great if MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES would also work for this use case.

Tested with Jackson 2.8.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions