多层嵌套json解析

JSONObject result = JSONObject.parseObject(response);
if(!"0".equals(result.getString("rtn"))){
    return  "错误";
}else{
    for(Object jsonArray : result.getJSONArray("pair_results")){
        TAlert tAlert = new TAlert();
        JSONObject jsonObject = (JSONObject)jsonArray;
        JSONObject jsonDetail = JSONObject.parseObject(jsonObject.getString("hit_detail"));
        tAlert.setHitRecordId(jsonDetail.getString("hit_record_id"));
        JSONObject jsonResult1 = JSONObject.parseObject(jsonObject.getString("result1"));
        tAlert.setResult1cameraId(jsonResult1.getString("camera_id"));
        int a  = tAlertMapper.insert(tAlert);
        //boolean b = itAlertService.save(tAlert);
        System.out.println(a);
    }

版权声明:本文为ccsd11原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。