json解析——fastjson
来源:互联网 发布:淘宝卖家快递推荐 编辑:程序博客网 时间:2024/05/27 10:43
使用fastjson首先要下载jar包 http://code.alibabatech.com/mvn/releases/com/alibaba/fastjson/1.0.4/fastjson-1.0.4.jar
假设有两个实体:
student:id,name,age
teacher:id,name,students
将实体解析为json字符串:
Student student = new Student(0, "lisi", 1);
System.out.println(JSON.toJSONString(student));
System.out.println(JSON.toJSONString(student,true)); 按照标准的json格式输出
自定义需要序列化的字段
SimplePropertyPreFilter filter = new SimplePropertyPreFilter(实体类.class, "字段1","字段2");
JSON.toJSONString(students,filter);
将json字符串反序列化为实体:
JSON.parseObject(str,Student.class);
更详细内容参考:http://www.cnblogs.com/Jie-Jack/p/3758046.html
阅读全文
1 0
- json解析——fastjson
- Android解析JSON数据(三)——FastJson解析
- JSON——fastjson
- Json解析,FastJson解析
- FastJson——生成和解析Json数据
- JSON数据解析(三)——FastJson
- JSON数据解析(三)——FastJson
- JSON数据解析(三)——FastJson
- JSON 之FastJson解析
- Android FastJson,json解析
- JSON 之FastJson解析
- JSON 之FastJson解析
- Json解析之FastJson
- JSON 之FastJson解析
- JSON 之FastJson解析
- JSON 之FastJson解析
- JSON 之FastJson解析
- JSON 之FastJson解析
- 学习Promise
- Google Guava--让java代码更加优雅
- PAT 1044火星数字
- UCOSii-信号量
- C语言指针专题——使用指针要注意这些
- json解析——fastjson
- [US Giants] 二. Integer-Array
- Java语言为什么可以跨平台
- 谷歌教机器人理解语义,像人一样学习复杂技能 | 附3篇论文
- Linux内存管理机制
- SpringMCV运行流程及整合spring
- Java面试知识总结
- 英语六级备考策略
- 1106: 回文数(函数专题)