国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

  • <label id="aoqoo"></label>

    <center id="aoqoo"></center>
    <span id="aoqoo"></span>

    1. FastJson教學(xué)手冊 / Fastjson 定制序列化

      Fastjson 定制序列化

      Fastjson 定制序列化

      1. 簡介

      fastjson支持多種方式定制序列化。

      • 通過@JSONField定制序列化
      • 通過@JSONType定制序列化
      • 通過SerializeFilter定制序列化
      • 通過ParseProcess定制反序列化

      2. 使用@JSONField配置

      可以把@JSONField配置在字段或者getter/setter方法上。例如:

       public class VO {
            @JSONField(name="ID")
            private int id;
       }

      或者

       public class VO {
            private int id;
      
            @JSONField(name="ID")
            public int getId() { return id;}
      
            @JSONField(name="ID")
            public void setId(int value) {this.id = id;}
       }

      更多看這里:JSONField

      3. 使用@JSONType配置

      和JSONField類似,但JSONType配置在類上,而不是field或者getter/setter方法上。

      4. 通過SerializeFilter定制序列化

      通過SerializeFilter可以使用擴展編程的方式實現(xiàn)定制序列化。fastjson提供了多種SerializeFilter:

      • PropertyPreFilter 根據(jù)PropertyName判斷是否序列化
      • PropertyFilter 根據(jù)PropertyName和PropertyValue來判斷是否序列化
      • NameFilter 修改Key,如果需要修改Key,process返回值則可
      • ValueFilter 修改Value
      • BeforeFilter 序列化時在最前添加內(nèi)容
      • AfterFilter 序列化時在最后添加內(nèi)容
      SerializeFilter filter = ...; // 可以是上面5個SerializeFilter的任意一種。
        JSON.toJSONString(obj, filter);

      更多看這里: SerializeFilter

      5. 通過ParseProcess定制反序列化

      定制反系列化API ParseProcess