我有这样的回应:
{ "songs":{ "2562862600":{"id":"2562862600""pos":1}, "2562862620":{"id":"2562862620""pos":1}, "2562862604":{"id":"2562862604""pos":1}, "2573433638":{"id":"2573433638""pos":1} } }
这是我的代码:
List<NameValuePair> param = new ArrayList<NameValuePair>(); JSONObject json = jParser.makeHttpRequest(url, "GET", param); JSONObject songs= json.getJSONObject("songs");
如何转换"songs"为JSONArray?
"songs"
像这样:
JSONObject songs= json.getJSONObject("songs"); Iterator x = songs.keys(); JSONArray jsonArray = new JSONArray(); while (x.hasNext()){ String key = (String) x.next(); jsonArray.put(songs.get(key)); }