JSONObject quotesObject = new JSONObject(responseStr);
Log.e("leb","4");
//get it as array
JSONArray projects = quotesObject.getJSONArray("project");
我从我的服务器获得了Json。 而这些是我的错误信息:为什么不能将JSONObject转换为JSONArray
12-19 11:56:17.314: W/System.err(456): org.json.JSONException: Value {"category":"1","Body":"eeee","Price":"110.0","ID":"1","NowPrice":"10.0","idRef":"1","user":"1","Title":"I"} at project of type org.json.JSONObject cannot be converted to JSONArray
12-19 11:56:17.374: W/System.err(456): at org.json.JSON.typeMismatch(JSON.java:96)
12-19 11:56:17.374: W/System.err(456): at org.json.JSONObject.getJSONArray(JSONObject.java:548)
12-19 11:56:17.413: W/System.err(456): at com.supinfo.sup.rest.ProjectRestDao$RestTaskGetAll.doInBackground(ProjectRestDao.java:197)
12-19 11:56:17.434: W/System.err(456): at com.supinfo.sup.rest.ProjectRestDao$RestTaskGetAll.doInBackground(ProjectRestDao.java:1)
12-19 11:56:17.434: W/System.err(456): at android.os.AsyncTask$2.call(AsyncTask.java:185)
12-19 11:56:17.434: W/System.err(456): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
12-19 11:56:17.434: W/System.err(456): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
12-19 11:56:17.434: W/System.err(456): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
12-19 11:56:17.434: W/System.err(456): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
12-19 11:56:17.434: W/System.err(456): at java.lang.Thread.run(Thread.java:1096)
因为这里显示的json不是数组。 – Nfear
这个JSON表示不是JSON数组的JSON对象! – Pavlos
服务器响应中没有JSON数组。 –