JSON对象操作

---string 转jsonObject

JSONObject j = JSONObject.fromObject(str); 

JSONObject j = JSONObject.fromObject(group);
JSONArray ja = (JSONArray) j.get("groups");
List<Map<String,String>> groupList = new ArrayList<Map<String,String>>();

for(int i =0;i<ja.size();i++){
Map<String,String> m = new HashMap<String, String>();

JSONObject js = (JSONObject)ja.get(i);
--遍历jsonObject对象
Iterator<String> iterator = js.keys();
while(iterator.hasNext()) {
String jsonKey = iterator.next();
String value = js.get(jsonKey).toString();
m.put(jsonKey, value);
System.out.print(jsonKey+" "+value+" ");
}

你可能感兴趣的:(JSON对象操作)