EN
Jackson - prevent field serialization with @JsonIgnore
6
points
In this short article, we would like to show how to ignore some fields serialization working with Jackson library.
Quick solution (use @JsonIgnore annotation):
package com.example;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation;
@Entity
@Table(name = "users")
public class UserEntiy {
// some fields here ...
@JsonIgnore
String ignoredField;
// some fields here ...
}
Note:
@JsonIgnorecauses the field will be omitted and not serialized by Jackson (use@JsonPropertyto get same effect on deserialization).