您的位置:首页 > 移动开发 > Objective-C

JSONObject json

2016-07-08 12:53 381 查看
1、为什么model里面的类都要继承JSONObject:

一个功能强大的串行化库

支持json,xml,等

这个就关系到了json的应用了

轻量级数据交换格式

 

JSONObject:

可以输出

public static void main(String[] args) {

Map<String,Object> map = new HashMap<String,Object>();

map.put("int", new Integer(1));

map.put("brr",new int[]{1,2,2});

map.put("arr",new int[]{1,2,2});

map.put("fun", "function(i){return this.arr}");

JSONObject json =
JSONObject.fromObject(map);

System.out.println(json);

}

输出:(默认排序是根据key的首字母排序):{"arr":[1,2,2],"int":1,"brr":[1,2,2],"fun":function(i){return this.arr}}

import com.alibaba.fastjson.JSONObject;

与其他的有什么不同之处
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: