遍历jsonArray
String str = "[{name:'a',value:'aa'},{name:'b',value:'bb'},{name:'c',value:'cc'}]" ;
JSONArray json = JSONArray.fromObject(str );
if(json.size()>0){
for(int i=0;i<json.size();i++){
JSONObject job = json.getJSONObject(i);
System.out.println(job.get("name")+"=") ;
}
}
遍历jsonObject
JSONObject jsonObject = new JSONObject(jsonString);
Iterator iterator = jsonObject.keys();
while(iterator.hasNext()){
key = (String) iterator.next();
value = jsonObject.getString(key);
}