首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

json转入java的vo对象

2012-10-29 
json转为java的vo对象String str [{name:hello,age:21},{name:hello2,age:22},{name:he

json转为java的vo对象

String str = "[{'name':'hello',age:'21'},{'name':'hello2',age:'22'},{'name':'hello3',age:'23'}]";JSONArray jsonArray = JSONArray.fromObject(str);List list = new ArrayList();for ( int i = 0 ; i<jsonArray.size(); i++){          JSONObject jsonObject = jsonArray.getJSONObject(i);TestUserVo vo = (testUserVo) JSONObject.toBean(jsonObject,TestUserVo.class); System.out.println(vo.getAge()); list.add(vo);            }  
      1 楼 jimmycheng 2010-05-21   讨论个问题:
    目前我碰到这样的,就是比如;TestUserVo 里面还有个内部类,那转成VO后,我去获取内部类的值的时候就出问题了, 类型转换出错
java.lang.ClassCastException: net.sf.ezmorph.bean.MorphDynaBean cannot be cast to Infos$DomainInfo

热点排行