服务器端:
ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
HashMap<String,String> map1 = new HashMap<String,String>();
map1.put("name","violet");
map1.put("sex","nv");
list.add(map1);
JSONObject jo = new JSONObject();
jo.put("stulist",list);
PrintWriter pw = response.getWriter();
pw.priintln(jo);
pw.flush();
pw.close();
客户端:
JSONObject jo = new JSONObjet(data);
JSONArray ja = jo.getJSONArray();
for(int i=0;i<ja.length();i++){
JSONObject jtemp = ja.getJSONObject(i);
String name = jtemp.getString("name");
String sex = jtemp.getString("sex");
}
网友评论