-
常用框架:阿里,fastjson,谷歌,gson等。
-
javaBean序列化为json
① 性能:Jackson > Fastjson > Gson > Json-lib同个结构
② Jackson、Fastjson、Gson 类库各有特点,各有自己的专长
③ 空间换时间,时间换空间 -
jackson处理相关自动
① 指定字段不返回:@jsonIgnore(主要用于密码,让密码不显示,加在字段上面)
② 指定日期格式:@JsonFormat(pattern = “yyyy-MM-dd hh:mm:ss”,locale = “zh”,timezone = “GMT+8”)
③ 空字段不返回:@JsonInclude(JsonInclude.Include.NON_NULL)
③ 指定别名:@JsonProperty(“create_time”) -
开发功能:视频创建时候返回自定义格式,过滤用户敏感信息。
private int price;
@JsonProperty("cover_img")
private String coverImg;
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss",locale = "zh",timezone = "GMT+8")
@JsonProperty("create_time")
private Date createTime;
@JsonInclude(JsonInclude.Include.NON_NULL)
private List<Chapter> chapterList;