public void parseSearchDirectAllData(ArrayList programmeSites) { if(programmeSites != null) { programmeSites.clear(); try { JSONArray segsArray = new JSONArray(jsonString); if (segsArray != null) for (int k = 0; k 0) { for (int i = 0; i 0) { ArrayList episodes = new ArrayList(); for (int j = 0; j < jsonResultsSerisesArray.length(); j++) { JSONObject jsonResultSerisesObject = jsonResultsSerisesArray.optJSONObject(j); if(jsonResultSerisesObject != null) { Episode episode = new Episode(); episode.setName(jsonResultSerisesObject.optString("name")); episode.setUrl(jsonResultSerisesObject.optString("url")); episodes.add(episode); } } programmeSite.setEpisodes(episodes); } } programmeSites.add(programmeSite); } } } } } } } catch (Exception e) { Logger.e(Youku.TAG_GLOBAL, "ParseJson#parseSearchDirectAllData()", e); } } }
上面代碼輸入JSON數據如下:
[ "programmeSite": [ {//begin "id": 405642, "siteId": 17, "episode":[ { "url": "https://www.letv.com/ptv/vplay/1606059.html", "name": "黑狐01", "seconds": 2701, "orderId": 1, "orderStage": 1, "lastUpdate": 1376496000, "viewOrder": 1, "logo": "", "tagType": 0, "vid": 0, }, { "url": "https://www.letv.com/ptv/vplay/1427315.html", "name": "黑狐02", "seconds": 2699, "orderId": 2, "orderStage": 2, "lastUpdate": 1376496000, "viewOrder": 1, "logo": "", "tagType": 0, "vid": 0, }, ] }//end {//begin "id": 405715, "siteId": 1, "episode": [ { "url": "https://www.tudou.com/albumplay/hLzWIWJyMXk/AHf67i8rVrg.html", "name": "黑狐-第1集", "seconds": 2699, "orderId": 1, "orderStage": 1, "lastUpdate": 1386604800, "viewOrder": 2, "logo": "https://r3.ykimg.com/0543040850EB192B6A0A470A11CD1DA6", "tagType": 0, "vid": 130472276, }, { "url": "https://www.tudou.com/albumplay/hLzWIWJyMXk/XaJL16jobbE.html", "name": "黑狐-第2集", "seconds": 2699, "orderId": 2, "orderStage": 2, "lastUpdate": 1387468800, "viewOrder": 2, "logo": "https://r3.ykimg.com/0543040850BE87EF6A0A442EFAD0048F", "tagType": 0, "vid": 130472277, }, ] }//end ] ]