作用
告诉 Jackson 在处理时忽略该注解标注的 java pojo 属性,
不管是将 java 对象转换成 json 字符串,还是将 json 字符串转换成 java 对象。
该注解与@JsonIgnore类似,但该注解是 类级别 的,并且可以同时 指定多个属性
例子
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(value = {"createTime","updateTime"})
public class Student {
private String id;
private String username;
private String password;
private Date createTime;
private Date updateTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}