The easy way is to annotate your getters and setters.
Here is the original example modified to exclude the plain text password, but then annotate a new method that just returns the password field as encrypted text.
class User {
private String password;
public void setPassword(String password) {
this.password = password;
}
@JsonIgnore
public String getPassword() {
return password;
}
@JsonProperty("password")
public String getEncryptedPassword() {
// encryption logic
}
}