@JsonIgnore
— a Jackson annotation used to exclude a field or method from JSON serialization or deserialization.
🧩 Purpose
Prevents sensitive or unnecessary data from appearing in JSON responses or being read from incoming JSON.
Example:
public class User {
private String username;
@JsonIgnore
private String password;
// getters & setters
}
✅ When serialized:
{
"username": "john"
}
The password
field is ignored — not included in the output or parsed from input.
🧠 Key Points
- Comes from
com.fasterxml.jackson.annotation
. - Can be applied to fields or getters/setters.
- If you need conditional control, use
@JsonIgnoreProperties
or@JsonInclude
.