Let's say I have a POJO like:
public class User {
private Long id;
private String username;
// usual getters and setters
....
// only for serialisation purposes
public String getUpperUsername() {
return this.id % 2 == 0 ? username : username.toUpperCase();
}
}
I would like to make a conditional serializer so that it serialises a different value that the actual one if some conditions are satisfied.
I looked at @JsonGetter but apparently it's deprecated, @JsonProperty doesn't seem to work.
Do you have any idea?
Thank you in advance :)