We are serializing/deserializing JSON using jackson 2.11.0 and using visibility settings to force the use of field-level access instead of via setter/getters:
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
mapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE);
However, certain 3rdparty classes have specific properties that we want generated by getter methods, and not the raw field value. We cannot modify these classes directly. I tried doing a mixin to make this happen but never figured it out. I'd prefer not to write a custom serializer/deserializer for this use case if possible.
Here's a simplified example: If a create a Foo object (below) and serialize it, I'd like the output to be: {"bar": "XXbarXX"}
public class Foo {
private String bar = "bar";
public String getBar() {
return "XX" + bar + "XX";
}
}