JSON 对象处理
来源:互联网 发布:十代思域轮毂改装数据 编辑:程序博客网 时间:2024/05/21 06:51
常见的java代码转换成json
--请注意,这个方法曾经给我造成过困惑。因为,它在对Object转换的时候是按照domain类中的所有getXXX()方法进行转换的。如果你在类中写了非属性的getXXX()方法,那么返回给你的就会有XXX属性了。
--使用net.sf.json.*下的类(jar包是json-lib-x.x.jar)
1. List集合转换成json代码
List list = new ArrayList();
list.add( "first" );
list.add( "second" );
JSONArray jsonArray2 = JSONArray.fromObject( list );
2. Map集合转换成json代码
Map map = new HashMap();
map.put("name", "json");
map.put("bool", Boolean.TRUE);
map.put("int", new Integer(1));
map.put("arr", new String[] { "a", "b" });
map.put("func", "function(i){ return this.arr[i]; }");
JSONObject json = JSONObject.fromObject(map);
3. Bean转换成json代码
JSONObject jsonObject = JSONObject.fromObject(new JsonBean());
4. 数组转换成json代码
boolean[] boolArray = new boolean[] { true, false, true };
JSONArray jsonArray1 = JSONArray.fromObject(boolArray);
5. 一般数据转换成json代码
JSONArray jsonArray3 = JSONArray.fromObject("['json','is','easy']" );
- 处理JSON对象
- jackson处理json对象
- jquery处理JSON对象
- JSON 对象处理
- JSON对象处理总结
- Java处理JSON对象
- json对象处理
- [Json]json-lib简单处理java对象变为json对象
- JS 处理json 对象或json串
- json 处理得到 json对象 操作JSONObject
- 异步请求、处理JSON对象
- json复杂对象处理jsonConfig
- 处理复杂的JSON对象
- JSON对象遍历和处理
- json对象后台处理心得
- json 对象常规处理方法
- MVC中处理Json和JS中处理Json对象
- MVC中处理Json和JS中处理Json对象
- 《ActiveMQ In Action》Chapter 3 The ActiveMQ in Action examples
- Android Zipalign--apk对齐优化
- Oracle表 序列 约束 视图 索引的操作
- 传值选择初始化显示的widget
- VS2013编译libpng库
- JSON 对象处理
- ios sqlite框架FMDB 的简单应用
- ios build时,Undefined symbols for architecture xxx问题的总结
- 【JAVA】:java中getTime函数
- 安卓5.0六大最烦人问题与解决方法
- activemq web console的权限配置
- Android 使用动态加载框架DL进行插件化开发
- http 和 https 的请求区别
- 反省,冲击