json 转换 java 集合的问题

json  转换 java 集合的问题

问题描述:

    1. jsonObject = new JSONObject();
     2.jsonArray = JSONArray.fromObject(empList);
     3.jsonObject.put("empList", jsonArray);
     4.out.print(jsonObject.get("empList"));

struts2 + ext 执行到第2步的时候不报异常 ,但是用调适 就跑到下面图片里的那个类去了 谁知道是什么问题吗? 难大是hibernate 的映射关系吗?

[img]http://dl.iteye.com/upload/attachment/156488/f03bad87-84f8-39bc-953a-6ad363915064.png[/img]

如果是hibernate的代理集合的话,用JSONArray.fromObject(empList); 转换成json字符串可能是有问题的,因为JSONArray只能针对jdk的集合类进行转换,

你这个是empList是用hibernate查询出来的吗,有可能是hibernate的代理集合类哦