阿里巴巴的fastjson使用分析
来源:互联网 发布:java对list进行排序 编辑:程序博客网 时间:2024/05/22 16:49
1.阿里自称在服务端及安卓端能提供最好的性能、提供一个方便简单的对象与json相互转化的api、Allow pre-existing unmodifiable objects to be converted to and from JSON(这句翻译不出来)、广泛的支持java泛型、允许对象的自定义表示、支持任意复杂对象。
2.我把他们官方给的实例下载 也搬出来。
- public class Group {
- private Long id;
- private String name;
- private List<User> users = new ArrayList<User>();
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public List<User> getUsers() {
- return users;
- }
- public void setUsers(List<User> users) {
- this.users = users;
- }
- public void addUser(User user) {
- users.add(user);
- }
- @Override
- public String toString() {
- return "Group [id=" + id + ", name=" + name + ", users=" + users + "]";
- }
- }
- public class User {
- private Long id;
- private String name;
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- public String getName() {
- return name;
- } 下载
- public void setName(String name) {
- this.name = name;
- }
- }
- Group group = new Group();
- group.setId(0L);
- group.setName("admin");
- User guestUser = new User();
- guestUser.setId(2L);
- guestUser.setName("guest");
- User rootUser = new User();
- rootUser.setId(3L);
- rootUser.setName("root");
- group.addUser(guestUser);
- group.addUser(rootUser);
- String jsonString = JSON.toJSONString(group);
- System.out.println(jsonString);
- Group group2 = JSON.parseObject(jsonString, Group.class);
- System.out.println(group2);
- System.out.println(JSON.toJSONStringWithDateFormat(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"));
0 0
- 阿里巴巴的fastjson使用分析
- 阿里巴巴fastjson的使用
- SpringMVC杂记(1) 使用阿里巴巴的fastjson
- Java编程:阿里巴巴的fastjson使用示例
- SpringMVC杂记(1) 使用阿里巴巴的fastjson
- Json解析包 阿里巴巴 FastJson 的使用
- 阿里巴巴 - FastJson使用简介
- 阿里巴巴 - FastJson使用简介
- 阿里巴巴 - FastJson使用简介
- 阿里巴巴fastJson使用
- fastjson 阿里巴巴json使用
- 阿里巴巴的fastJson
- 阿里巴巴的fastjson
- Json的处理(阿里巴巴的fastjson)
- 阿里巴巴fastJson解析工具的demo实现
- 阿里巴巴FastJson对数据的常用操作
- FastJson-fastjson的简单使用
- 阿里巴巴FastJson解析
- http协议9---http协议总结
- 网页特效之弹出窗口控制
- NHK Easy News 翻译 12月22日-3
- Alluxio1.3.0源码编译
- git reflog
- 阿里巴巴的fastjson使用分析
- java集成支付宝支付接口(JSP+支付宝20160912)
- MyBatis(3):SQL映射
- 大小端问题网络字节序
- 0型文法、1型文法、2型文法、3型文法
- 过滤器模式
- 用淘宝接口通过ip查询地域
- COCOA多窗口编程及卷帘式显示
- pc端向手机发送验证码