I am trying to ignore a specified field from a list during deserialization. I am not sure how do i do that for a field that sits inside a list. Below is my json and response class
Sample json
{
"key": {
"rowKey": "123"
},
"names": [
{
"firstName": "JON ",
"firstNameFormatted": "JON"
}
]
}
Response class
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@ToString
public class Data {
private Map<String,Object> key;
private List<Map<String,Object>> names;
}
Here i would like to ignore
firstNameFormatted
from my json response but i am not sure how to do that using jackson for a field that is inside a list ?
Jackson has a solution for that. Simply use @JsonIgnore
You can see it in the example below
@JsonIgnore
public String getPassword() {
return password;
}
Now the password information won't be serialized to JSON.
Also you can try with @JsonIgnoreProperties
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.