Skip to content

Support @JsonView for @JsonAnySetter deserialization #6260

Open

Description

@cowtowncoder

@JsonView on a @JsonAnySetter is ignored when deserializing: values for unmatched properties are passed to the any-setter no matter which view is active. Regular properties already honor views, and so does @JsonAnyGetter when serializing.

So, for:

static class Bean {
    @JsonView(ViewA.class) public String a;
    @JsonAnySetter @JsonView(ViewB.class)
    public Map<String, Object> other = new LinkedHashMap<>();
}

mapper.readerWithView(ViewA.class).forType(Bean.class)
    .readValue("{\"a\":\"1\",\"x\":\"3\"}");

We currently get

other == {x=3}

but should get

other == {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions