String json= "{"+ "\"date\":{"+ "\"string1\":\"1\","+ "\"string2\":\"2\","+ "\"string3\":\"3\","+ "}"+ "}"; JSONObject jsonObject = JSON.parseObject(json); System.out.println(jsonObject.toString()); String date = jsonObject.get("date").toString(); JSONObject datas = JSON.parseObject(date); Set<String> strings = datas.keySet(); for (String key :strings) { Object value = datas.get(key); System.out.println("key="+key+",value="+value); }
日志输出:
{"date":{"string1":"1","string2":"2","string3":"3"}}
key=string3,value=3
key=string1,value=1
key=string2,value=2