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);
}
多层嵌套json解析
最新推荐文章于 2025-10-27 14:10:18 发布
本文介绍了一种从HTTP响应中解析JSON数据的方法,并将其转换为TAlert对象,然后将这些对象插入数据库的过程。重点关注了如何使用JSON操作库进行数据解析,以及如何通过数据库映射接口实现数据持久化。
2241

被折叠的 条评论
为什么被折叠?



