public void parseSearchDirectAllData(ArrayList
programmeSites) {if(programmeSites != null) {programmeSites.clear();try { JSONArray segsArray = new JSONArray(jsonString); if (segsArray != null)for (int k = 0; k < segsArray.length(); k++) {JSONObject segObject = segsArray.optJSONObject(k);if (segObject != null) {if(segObject.has("programmeSite")) {JSONArray jsonResultsArray = segObject.optJSONArray("programmeSite");if(jsonResultsArray != null && jsonResultsArray.length() > 0) {for (int i = 0; i < jsonResultsArray.length(); i++) {JSONObject jsonResultObject = jsonResultsArray.optJSONObject(i);if(jsonResultObject != null) {ProgrammeSite programmeSite = new ProgrammeSite();programmeSite.setSiteId(jsonResultObject.optInt("siteId"));if(jsonResultObject.has("episode")) {JSONArray jsonResultsSerisesArray = jsonResultObject.optJSONArray("episode");if(jsonResultsSerisesArray != null && jsonResultsSerisesArray.length() > 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);}}}
The JSON data entered in the above Code is as follows:
["ProgrammeSite": [{// begin "id": 405642, "siteId": 17, "episode": [{"url": "http://www.letv.com/ptv/vplay/1606059.html", "name ": "Black Fox 01", "seconds": 2701, "orderId": 1, "orderStage": 1, "lastUpdate": 1376496000, "viewOrder": 1, "logo ": "", "tagType": 0, "vid": 0, },{ "url": "http://www.letv.com/ptv/vplay/1427315.html", "name": "black fox 02", "seconds ": 2699, "orderId": 2, "orderStage": 2, "lastUpdate": 1376496000, "viewOrder": 1, "logo": "", "tagType": 0, "vid": 0,},]} // end {// begin "id": 405715, "siteId": 1, "episode": [{"url ": "http://www.tudou.com/albumplay/hLzWIWJyMXk/AHf67i8rVrg.html", "name": "black fox-1st set", "seconds": 2699, "orderId": 1, "orderStage": 1, "lastUpdate": 1386604800, "viewOrder": 2, "logo": "http://r3.ykimg.com/0543040850EB192B6A0A470A11CD1DA6", "tagType": 0, "vid": 130472276, },{ "url": "http://www.tudou.com/albumplay/hLzWIWJyMXk/XaJL16jobbE.html ", "name": "-2nd", "seconds": 2699, "orderId": 2, "orderStage": 2, "lastUpdate": 1387468800, "viewOrder ": 2, "logo": "http://r3.ykimg.com/0543040850BE87EF6A0A442EFAD0048F", "tagType": 0, "vid": 130472277,},]} // end]