//@JsonIgnoreProperties 后面写上不参与序列化的值
@JsonIgnoreProperties(value = { "id", "segmentId", "createDate", "modifyDate", "isDelete" })
public class Profile {
private Integer id;
private String userId;
//@JsonProperty("userid")指定序列化的名称
@JsonProperty("userid")
private Integer outUserId;
@JsonProperty("truename")
private String trueName;
@JsonProperty("kidname")
private String kidName;
@JsonProperty("alongwith")
private Byte alongWith;
@JsonProperty("childscount")
private Byte childCount;
@JsonProperty("childgender")
private Byte childGender;
//@JsonFormat适用于时间格式上的转化
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date regDate;
}
或者属性值为空的不参与序列化
//值为null 不参与序列化
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class Profile {
private Integer id;
private String userId;
@JsonProperty("userid")
private Integer outUserId;
@JsonProperty("truename")
private String trueName;
@JsonProperty("kidname")
private String kidName;
@JsonProperty("alongwith")
private Byte alongWith;
@JsonProperty("childscount")
private Byte childCount;
@JsonProperty("childgender")
private Byte childGender;
}