方法一
public static void main(String[] args) {
String testParam = "{\"id\":\"1001\",\"name\":\"oowangfanoo\",\"sex\":\"30\"}";
TestEntity testEntity = JSON.toJavaObject(JSONObject.parseObject(testParam),TestEntity.class) ;
System.out.println(testEntity.toString());
}
TestEntity 为自己创建的实体类
方法二
JSONArray jsonArray= JSONArray.parseArray(jsonObject.get("body").toString());
System.out.println(jsonArray +"::::"+ jsonArray.size());
for(int i=0;i<jsonArray.size();i++){
JSONObject object= (JSONObject) jsonArray.get(i);
System.out.println(object.get("cabinet_id"));
}
原文链接:https://blog.csdn.net/oowangfanoo/article/details/114025472