list集合转换JSON出异常 public void getstreet() { HttpServletRequest request = ServletActionContext.getRequest(); String areaid = request.getParameter("areaid"); System.out.println("-------aid--------->" +listarea); List<Street> listStreet = houseservice.listStreet(Integer.parseInt(areaid)); JSONObject jsonArray= JSONObject.fromObject(listStreet);} 这个是我方法listStreet 就是从数据库里面的到的值我用debug调式里面不为空有值 但是我用这个方法JSONObject jsonArray= JSONObject.fromObject(listStreet);的时候报出异常 严重: Servlet.service() for servlet default threw exception net.sf.json.JSONException: 'object' is an array. Use JSONArray instead at net.sf.json.JSONObject.fromObject(JSONObject.java:190) at net.sf.json.JSONObject.fromObject(JSONObject.java:154) at org.shj.houseproject.house.action.HouseAction.getstreet(HouseAction.java:181) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404) at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.j 不知道哪里出了问题
------解决方案--------------------
'object' is an array. Use JSONArray instead