Skip to content

Delegating JsonCreator disregards JsonDeserialize.as (and contentAs) annotation #2016

@carterkozak

Description

@carterkozak

Given a class of this form, the documentation suggests that value should be created as a LinkedList, however it is always an ArrayList. Furthermore, if I modify the @JsonDeserialize annotation with incorrect values (e.g. as = HashMap.class) it does not change behavior.

public final class Wrapper {
    private final List<String> value;

    @JsonCreator
    public Wrapper(@JsonDeserialize(as = LinkedList.class) List<String> value) {
        this.value = value;
    }

    @JsonValue
    public List<String> getValue() {
        return value;
    }
}

If I expect an object with a property by using a @JsonProperty annotation, the @JsonDeserialize annotation does work as expected.

Simple repro here:
https://github.com/cakofony/jackson-jsoncreator-deserializeas-repro

Test class is located here

Happy to provide additional info.
Thanks!

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