由于某种原因,我可以将整个数组读回来,但是当我尝试选择一个段时,它不让我看到数组中的段过去,数组长度等于1,就像所有被压扁成一个元素。这是我的代码:解析JSONObject中的JSONArray问题
https://github.com/yehudaclinton/Mytest/blob/master/TestHTTP.java
try { Object obj = parser.parse(result); JSONObject jsonObject = (JSONObject) obj; JSONArray items = (JSONArray) jsonObject.get("items"); Log.d(TAG, "items length: " + items.size());//for some reason is not more than 1 String name = ""; //the the following is supposed to return just the title of book for (int i = 0; i < items.size(); i++) { JSONObject item = (JSONObject) items.get(i);//if 'i' equals more then one program crashes if(item.get("title")!=null) {//only get the title JSONObject theTitle = (JSONObject) item.get("title"); name = (String) theTitle.get("title"); } }
结果=名称;
什么是堆栈跟踪? –