Only using @JsonIgnore during serialization, but not deserialization

I have a user object that is sent to and from the server. When I send out the user object, I don’t want to send the hashed password to the client. So, I added @JsonIgnore on the password property, but this also blocks it from being deserialized into the password that makes it hard to sign up users when they don’t have a password.

How can I only get @JsonIgnore to apply to serialization and not deserialization? I’m using Spring JSONView, so I don’t have a ton of control over the ObjectMapper.

Things I’ve tried:

  1. Add @JsonIgnore to the property
  2. Add @JsonIgnore on the getter method only

9 Answers
9

Leave a Comment