Skip to content

Mixin with @JsonProperry to override @JsonIgnore no longer works in 2.14.x #3813

Closed
@ddewaele

Description

@ddewaele

We are using a Mixin to override a @JsonIgnore field in a POJO.
This is done by declaring the field in the Mixin wih a @JsonProperty annotation.
We noticed this behavior is no longer valid in 2.14.x

Given the following code

public class MixinSample {

    public static class CustomerMixin {
        @JsonProperty  // Also tried @JsonIgnore(false)
        public String id;
    }

    public static void main(String[] args) throws Exception {
        Customer customer = new Customer();
        customer.setId("123");   // This POJO has a JsonIgnore on the id field
        customer.setName("Joe");

        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.addMixIn(Customer.class, CustomerMixin.class);
        System.out.println("objectMapper = " + objectMapper.writeValueAsString(customer));

    }
}

With jackson-databind 2.13.x it outputs as expected (Mixin overrides the JsonIgnore id field):

{"id":"123","name":"Joe"}

With jackson-databind 2.14.x it doesn't seem to take into account the mixin :

{"name":"Joe"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    to-evaluateIssue that has been received but not yet evaluated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions