fastjson注解的简单用法
@JSONType(orders = { "id", "name", "password", "reg", "birthday", "age" }, alphabetic = false)
public class Users extends Person {
private Integer id;
private String name;
private String password;
@JSONField(name="reg",format="yyyy-MM-dd")
private Date regTime;
@JSONField(name="birthday",format="yyyy-MM-dd HH:mm:ss")
private Date birth;
//省略了get、set方法,有参无参构造方法
}
@JSONType注解写在类上,其中 orders可以指定属性名排序,alphabetic可以指定是否按照属性名字母排序,默认为true,,ignores可以指定不转化为json的属性名
@JSONField注解写在属性上,其中 name可以指定转换后json中属性名,format可以指定格式