Chinaunix首页 | 论坛 | 博客
  • 博客访问: 433560
  • 博文数量: 138
  • 博客积分: 4114
  • 博客等级: 上校
  • 技术积分: 1341
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-14 20:41
文章分类

全部博文(138)

文章存档

2014年(1)

2013年(2)

2012年(78)

2011年(13)

2010年(34)

2009年(10)

我的朋友

分类: LINUX

2012-09-26 15:07:51

本文转自

http://blog.csdn.net/hyman_xie/article/details/6253240


json用来在客户端和服务器端之间传输数据很是简洁和方便,但是如果客户端传输的是对象数组的话,得做如下的处理:

  1. JSONArray testJSONArray=JSONArray.fromObject(testArrayStr);  
  2. Collection testArray=JSONArray.toCollection(testJSONArray);  
  3. if(testArray!=null && !testArray.isEmpty())  
  4. {  
  5.     Iterator it=testArray.iterator();  
  6.     while(it.hasNext())  
  7.     {  
  8.         JSONObject testJSONObj=JSONObject.fromObject(it.next());  
  9.         Test test=(Test) JSONObject.toBean(testJSONObj,Test.class);  
  10.         ...  
  11.     }  
  12. }  

阅读(1127) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~