GET和POST请求到之后开始解析;
首先服务器端JSON解析:
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");
}