Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ddewaele opened this issue Mar 7, 2023 · 1 comment
Closed
Labels
to-evaluate Issue that has been received but not yet evaluated

Comments

@ddewaele
Copy link

ddewaele commented Mar 7, 2023

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"}
@ddewaele ddewaele added the to-evaluate Issue that has been received but not yet evaluated label Mar 7, 2023
@ddewaele ddewaele changed the title Mixin with @JsonProperry to override @JsonIgnore no longer works in 2.14 Mixin with @JsonProperry to override @JsonIgnore no longer works in 2.14.x Mar 7, 2023
@cowtowncoder
Copy link
Member

Duplicate, close, leave #3812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to-evaluate Issue that has been received but not yet evaluated
Projects
None yet
Development

No branches or pull requests

2 participants