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):
xxxxxxxxxx
1
package com.example;
2
3
import javax.persistence.Entity;
4
import javax.persistence.Table;
5
import com.fasterxml.jackson.annotation;
6
7
8
name = "users") (
9
public class UserEntiy {
10
11
// some fields here ...
12
13
14
String ignoredField;
15
16
// some fields here ...
17
}
Note:
@JsonIgnore
causes the field will be omitted and not serialized by Jackson (use@JsonProperty
to get same effect on deserialization).