I have a class:
class MyClass {
@Getter
@Setter
int a;
@Getter
@Setter
int b;
public int getADivB() {
return a / b;
}
}
when serializing, I need all three properties to be serialized. however, if another java process deserializes the message, I would like Jackson to ignore the computed field. (don't ignore it all with @JSONIgnore)
deserialization code:
String json = ...
JsonNode root = this.mapper.readTree(json);
MyClass abdiv = this.mapper.readValue(root, MyClass.class);
source
share