JSON数据解析的问题,请高手帮忙
{"info":[{"name":"123","xy":111},{"name":"123","xy":111},{"name":"123","xy":111}]}
像这种结构怎么解析 name和xy
[解决办法]
刚写的Java代码,在手机上测试过的.
public static void demo() { String jsonstr = "{\"info\":[{\"name\":\"123\",\"xy\":111},{\"name\":\"123\",\"xy\":111},{\"name\":\"123\",\"xy\":111}]}"; JSONObject obj; try { obj = new JSONObject(jsonstr); JSONArray array = obj.getJSONArray("info"); for (int i = 0; i < array.length(); i++) { JSONObject item = (JSONObject) array.get(i); System.out.println(item.getString("name") + "_________" + item.getString("xy")); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }