JSONObject json

来源:互联网 发布:架构师和程序员的区别 编辑:程序博客网 时间:2024/06/05 23:06

1、为什么model里面的类都要继承JSONObject:

一个功能强大的串行化库

支持jsonxml,等

这个就关系到了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;

与其他的有什么不同之处



0 0
原创粉丝点击