@JsonIgnore:排除json序列化,将它标注在属性上不会进行json序列化
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",locale = "zh"):进行日期格式化
@JsonInclude(JsonInclude.Include.NON_NULL):当属性值为null时则不进行json序列化
@JsonProperty("uname"):属性设置别名
package boot.bean; import com.fasterxml.jackson.annotation.*; import java.util.Date; public class User { @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty("uname") private String name; @JsonIgnore private int age; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date birthday; public User(String name, int age, Date birthday) { this.name = name; this.age = age; this.birthday = birthday; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } @Override public String toString() { return "User{" + "name='" + name + '\'' + ", age=" + age + ", birthday=" + birthday + '}'; } }
标签:jackson,name,age,birthday,使用,Date,public,String From: https://www.cnblogs.com/ixtao/p/17054256.html