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
目前我碰到这样的,就是比如;TestUserVo 里面还有个内部类,那转成VO后,我去获取内部类的值的时候就出问题了, 类型转换出错
java.lang.ClassCastException: net.sf.ezmorph.bean.MorphDynaBean cannot be cast to Infos$DomainInfo