/* http://10.0.2.2:8080/index.jsp
* { students:[{name:'Livingstone',age:25},{name:'LS',age:26}], class:'09GIS' }
*/
private void Livingstone() {
try {
String URL = "http://10.0.2.2:8080/index.jsp";
// 獲取后臺返回的JSON對象 --> { students:[{name:'Livingstone',age:25},{name:'LS',age:26}],class:'09GIS班' }
JSONObject jObj = JsonUtil.getJSON(URL);
// 獲取學生數組 --> students:[{name:'Livingstone',age:25},{name:'LS',age:26}]
JSONArray jArr = jObj.getJSONArray("students");
// 獲取班級 --> class:'09GIS班'
String classname = jObj.getString("class");
// 根據索引獲取第一個學生的JSON對象 --> {name:'Livingstone',age:25}
JSONObject j1 = jArr.getJSONObject(0);
String studentInfo = jArr.length() + "個學生" + j1.getString("name")
+ j1.getInt("age");
} catch (Exception e) {
e.printStackTrace();
}
}