String转jsonarry:字符串:[{"result":"20"},{"result":"21"},{"result":"20"},{"result":"22"}]
List<HashMap<String, Object>> grididmap = new ArrayList<HashMap<String,Object>>();
String a = bs.toString(); //bs的字符串为如下形式:[{"result":"20"},{"result":"21"},{"result":"20"},{"result":"22"}]
a=a.replace("[", "").replace("]", "");
String []arr = a.split(",");
for(int i=0;i<arr.length;i++){
HashMap<String, Object> map1 = new HashMap<String, Object>();
map1.put("result", JSONObject.fromObject(arr[i]).get("result"));
grididmap.add(map1);
}
System.out.println(grididmap.toString());
//转换后形式为:[{result=20},{result=21},{result=20},{result=22}]
//获取转换后的某个字段
obj.put("gridid",grididmap.get(index).get("result"));