I have a User class that I want to map to JSON using Jackson.
public class User {
private String name;
private int age;
prviate int securityCode;
You have two options:
Jackson works on setters-getters of fields. So, you can just remove getter of field which you want to omit in JSON. ( If you don't need getter at other place.)
Or, you can use the @JsonIgnore
annotation of Jackson on getter method of that field and you see there in no such key-value pair in resulted JSON.
@JsonIgnore
public int getSecurityCode(){
return securityCode;
}