I have an object that I would like to serialize with an attribute in one part of my program, but not in another part. I also have an ObjectMapper that is widely customizable, which I use for both serialization. My first inclination was to use Mixin for customization if the attribute is shown, but it seems that you can only put them in the ObjectMapper and not on the reader returned by ObjectMapper. Basically, the code that I would like to write will look like this.
ObjectMapper myMapper = new ObjectMapper(); // in reality there is a lot of customization
Foo foo = myMapper.reader().withMixin(Foo.class, FooMixin.class).readValue(jsonParser, Foo.class);
source
share