Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

定制序列化

wenshao edited this page Oct 4, 2014 · 24 revisions

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

  • 通过@JSONField定制序列化
  • 通过@JSONType定制序列化
  • 通过SerializeFilter定制序列化

通过@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 int getId() { return id;}
 }
Clone this wiki locally