listJson(JSON.parseObject("jsonstr"));
public void listJson(Object objJson) {
if (objJson instanceof JSONArray) {
JSONArray jsonArray = (JSONArray) objJson;
if (jsonArray.size() > 0) {
for (int i = 0; i < jsonArray.size(); i++) {
listJson(jsonArray.getJSONArray(i));
}
}
} else if (objJson instanceof JSONObject) {
JSONObject jsonObject = (JSONObject) objJson;
Set<String> keySet = jsonObject.keySet();
Iterator<String> iterator = keySet.iterator();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = jsonObject.get(key);
if (value instanceof JSONArray) {
JSONArray innerArr = (JSONArray) value;
listJson(innerArr);
} else if (value instanceof JSONObject) {
listJson(value);
} else {
System.out.println(key + "<<===>>" + value.toString());
}
}
}
}