In my entity class, I’m trying to make a write-only field (gets ignored during serialization, but gets de-serialized normally).
@JsonProperty
@JsonSerialize(using=NullSerializer.class)
public String getPassword() {
return password;
}
This almost gives me what I want: the JSON contains the “password” field, but the value is always null. How do I remove the field entirely?
Use
@JsonIgnoreon just the gettergetPassword, instead of using theNullSerializer. Then also use@JsonProperty("password")on the setter.This should allow
passwordto be de-serialized, but the JSON output of serialization won’t include it.