JSONObject jsonObject = new JSONObject(s);
然后用Iterator迭代器遍历取值,建议用反射机制解析到封装好的对象中
JSONObject jsonObject = new JSONObject(jsonString); Iterator iterator = jsonObject.keys(); while(iterator.hasNext()){ key = (String) iterator.next(); value = jsonObject.getString(key);
}
如果还想获得key 值:
JSONObject rawJson = JSONObject.parseObject(jsonString);
Set<String> set = jsonObject.keySet();
for (String key : set) {
rawJson.fluentPut(key, jsonObject.get(key).toString());//放入rawjson对象中
}