码迷,mamicode.com
首页 > 编程语言 > 详细

java merge json

时间:2019-02-12 13:01:43      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:nbsp   port   ++   bfd   new   sys   print   sel   bfc   

    public void import7(){
        
        
        List<Map<String, Object>> list = jdbcTemplate
                .queryForList("SELECT img_md5,tag_json FROM tag_img WHERE type_id=‘ff4dfd4ba7d949958b3d630a90fcca75‘ and tag_flag=1 and del_flag=1");

        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            
            
            TagImgFilter filter = new TagImgFilter();//更改的集合
            filter.setEq_orgId("c1fa7ba875fa4c9a899e2787eb79e802");
            filter.setEq_setId("47889ca50c0849dfb6cd6070ab2ddc46");
            filter.setEq_typeId("114e2331338e481cb4fd3a65aff4bfc8");
            filter.setEq_imgMd5(imgMd5);
                        
            TagImg imgnew = tagImgService.selectAll(filter).get(0);
            JSONArray arraynew = new JSONArray();
            if(imgnew.getTagJson() != null){
                arraynew=JSONArray.parseArray(imgnew.getTagJson());
            }
            
            /*if(array.size()!=8){
                System.out.println("不足8个框"+array.size()+"   img_md5:"+tagimg.get("img_md5").toString());
                break;
            }*/
            
            for(int countjson=0;countjson<array.size();countjson++){
                JSONObject jsonObj = array.getJSONObject(countjson);
                arraynew.add(jsonObj);
            }
            System.out.println(arraynew);
            imgnew.setTagJson(arraynew.toString());
            tagImgService.save(imgnew);
            
        }
        
        
        /*List<Map<String, Object>> list = jdbcTemplate
                .queryForList("SELECT img_md5,tag_json FROM tag_img WHERE type_id=‘52336e7e43204fa68c006692b355137a‘");

        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            
            
            TagImgFilter filter = new TagImgFilter();//更改的集合
            filter.setEq_orgId("c1fa7ba875fa4c9a899e2787eb79e802");
            filter.setEq_setId("47889ca50c0849dfb6cd6070ab2ddc46");
            filter.setEq_typeId("56329bfd7ad14d039cd1fdc4bc726316");
            filter.setEq_imgMd5(imgMd5);
                        
            TagImg imgnew = tagImgService.selectAll(filter).get(0);
            JSONArray arraynew=JSONArray.parseArray(imgnew.getTagJson());
            if(array.size()!=8){
                System.out.println("不足8个框"+array.size()+"   img_md5:"+tagimg.get("img_md5").toString());
                break;
            }
            
            for(int countjson=0;countjson<array.size();countjson++){
                JSONObject jsonObj = array.getJSONObject(countjson);
                arraynew.add(jsonObj);
            }
            System.out.println(arraynew);
            imgnew.setTagJson(array.toString());
            tagImgService.save(imgnew);

        }
*/        
        
        
    }

 

java merge json

标签:nbsp   port   ++   bfd   new   sys   print   sel   bfc   

原文地址:https://www.cnblogs.com/lely/p/10364597.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!