js通过ajax传给后台一个json数组字符串:
[{'prjcode':'4209222012A00','countyname':'大悟县','pro_1':'A','pro_2':'A','pro_3':'A','pro_4':'A','pro_5':'A','pro_6':'A','pro_7':'A','pro_8':'A','pro_9':'A','pro_10':'A','pro_11':'A','pro_12':'A','pro_13':'A','pro_14':'A','pro_15':'A'},{'prjcode':'4209222005A03','countyname':'大悟县','pro_1':'A','pro_2':'A','pro_3':'A','pro_4':'A','pro_5':'A','pro_6':'A','pro_7':'A','pro_8':'A','pro_9':'A','pro_10':'A','pro_11':'A','pro_12':'A','pro_13':'A','pro_14':'A','pro_15':'A'},{'prjcode':'4209222005B00','countyname':'大悟县','pro_1':'A','pro_2':'A','pro_3':'A','pro_4':'A','pro_5':'A','pro_6':'A','pro_7':'A','pro_8':'A','pro_9':'A','pro_10':'A','pro_11':'A','pro_12':'A','pro_13':'A','pro_14':'A','pro_15':'A'}]
String jsonstr = request.getParameter("jsonstr");
JSONArray json = JSONArray.fromObject(jsonstr);
Object[] obj=json.toArray();
for(int i=0;i<obj.length;i++){
JSONObject object = JSONObject.fromObject(obj[i]);
String prjcode=object.get("prjcode").toString();
String countyname=object.getString("countyname").toString();
String pro_1=object.getString("pro_1").toString();
String pro_2=object.getString("pro_2").toString();
String pro_3=object.getString("pro_3").toString();
String pro_4=object.getString("pro_4").toString();
String pro_5=object.getString("pro_5").toString();
String pro_6=object.getString("pro_6").toString();
String pro_7=object.getString("pro_7").toString();
String pro_8=object.getString("pro_8").toString();
String pro_9=object.getString("pro_9").toString();
String pro_10=object.getString("pro_10").toString();
String pro_11=object.getString("pro_11").toString();
String pro_12=object.getString("pro_12").toString();
String pro_13=object.getString("pro_13").toString();
String pro_14=object.getString("pro_14").toString();
String pro_15=object.getString("pro_15").toString();
}
posted on 2012-08-16 22:36
zhanghu198901 阅读(2478)
评论(0) 编辑 收藏