java merge json出错删除相同的json
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                java merge json出错删除相同的json
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                
                            
                            
                            /** 需要從數據庫里獲取 from tag_img tg LEFT JOIN img_center imc ON* tg.img_md5=imc.img_md5 left join img_case c on imc.case_id=c.id* * where c.source_id='3f8b081edd0c4060805bf6a077f30679' and img_info LIKE* '%脊柱側彎%'*/public void import8(){List<Map<String, Object>> list = jdbcTemplate.queryForList("SELECT img_md5,tag_json FROM tag_img WHERE type_id='ff4dfd4ba7d949958b3d630a90fcca75' and tag_flag=1 limit 22,5");System.out.println(list.size());        int i=0;for(Map<String,Object> tagimg:list){      i++;System.out.println(i);String imgMd5 = tagimg.get("img_md5").toString();JSONArray array=JSONArray.parseArray(tagimg.get("tag_json").toString());//得到原來的json        
            System.out.println(array);TagImgFilter filter = new TagImgFilter();//更改的集合filter.setEq_orgId("c1fa7ba875fa4c9a899e2787eb79e802");filter.setEq_setId("d5e8f01a2e6649cf877eacda8ceb6ff1");filter.setEq_typeId("52336e7e43204fa68c006692b355137a");filter.setEq_imgMd5(imgMd5);TagImg imgnew = tagImgService.selectAll(filter).get(0);JSONArray arraynew=JSONArray.parseArray(imgnew.getTagJson());System.out.println("11111111111");System.out.println(arraynew);for(int countjson=0;countjson<array.size();countjson++){JSONObject jsonObj = array.getJSONObject(countjson);for(int countjsonnew=0;countjsonnew<arraynew.size();countjsonnew++){JSONObject jsonDBle = arraynew.getJSONObject(countjsonnew);if (jsonObj.get("x").equals(jsonDBle.get("x")) && jsonObj.get("y").equals(jsonDBle.get("y")) && jsonObj.get("width").equals(jsonDBle.get("width")) && jsonObj.get("height").equals(jsonDBle.get("height"))){System.out.println(jsonDBle);arraynew.remove(jsonDBle);}System.out.println(arraynew);System.out.println(arraynew.size());}}imgnew.setTagJson(arraynew.toString());tagImgService.save(imgnew);}}  
                        
                        
                        ?
轉載于:https://www.cnblogs.com/lely/p/10364601.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的java merge json出错删除相同的json的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: json字符串与java对象的相互转换(
- 下一篇: oracle 清理跟踪文件trc,trm
