fastjson之serializer.SimplePropertyPreFilter
来源:互联网 发布:java线程池使用实例 编辑:程序博客网 时间:2024/05/21 03:57
需要根据不同的环境返回定制化返回属性时,可以使用SimplePropertyPreFilter
自定义实体类
public class Area { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; @Column(name="name",length=100) private String name; @Column(name = "code", length = 20) private String code; //省略了get,set方法和构造方法}
测试类
import com.alibaba.fastjson.JSONObject;import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;public void test() { /*1.获取区域表获取数据,以列表返回 findAreaChild()自定义方法*/ List<Area> areas = areaService.findAreaChild(areaid); /*2.定制序列化 只序列化id和名称*/ SimplePropertyPreFilter filter = new SimplePropertyPreFilter(Area.class, "id", "name"); /*3.JSONObject.toJSONString() 将JavaBean序列化为JSON文本*/ System.out.println(JSONObject.toJSONString(areas, filter));}
0 0
- fastjson之serializer.SimplePropertyPreFilter
- fastjson之serializer.SerializerFeature
- 關於 fastjson 中的 SimplePropertyPreFilter
- fastjson.serializer.SerializerFeature
- 在fastjson中使用SimplePropertyPreFilter忽略指定属性
- serializer
- ogre 不常用类记录之Serializer
- JSON 之FastJson解析
- JSON 之FastJson解析
- Json工具之FastJson
- JSON 之FastJson解析
- Json解析之FastJson
- JSON 之FastJson解析
- JSON 之FastJson解析
- JSON 之FastJson解析
- JSON之fastJson
- JSON 之FastJson解析
- JSON 之FastJson解析
- CDQ分治——BZOJ3295/Luogu3157 [CQOI2011]动态逆序对
- 运行的时候报 variables may not be available.
- Yacc 与 Lex-词法分析器工具
- Git仓库完整迁移 含历史记录
- L2-024. 部落
- fastjson之serializer.SimplePropertyPreFilter
- Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException
- 8个hybrid app开发工具
- Mac Safari 打不开网页,因为无法连接到服务器
- WebViewClient与WebChromeClient的区别
- kafka数据可靠性深度解读
- Cafffe入门-win7上训练自己的数据和微调
- [php] Thinkphp删除图片和数据库记录
- 昆石VOS3000_2.1.2.0完整安装包及安装脚本