java 给json的KEY改名
public void import10(){ TagImgFilter filter = new TagImgFilter();//更改的集合 filter.setEq_orgId("c1fa7ba875fa4c9a899e2787eb79e802"); filter.setEq_setId("d5e8f01a2e6649cf877eacda8ceb6ff1"); filter.setEq_typeId("52336e7e43204fa68c006692b355137a"); filter.setNull_tagJson(false);// 是否要有标注的,true是没标注 List<TagImg> imgList = tagImgService.selectAll(filter); System.out.println(imgList.size()); int countadd = 0; for (TagImg tagimg : imgList) { countadd++; System.out.println(countadd); String json=tagimg.getTagJson(); JSONArray array=JSONArray.parseArray(json); JSONArray arrayNew=new JSONArray(); if(array!=null && array.size()>0){ for(int i=0;i<array.size();i++){ JSONObject obj = array.getJSONObject(i); obj.put("classname",obj.get("mark")); obj.remove("mark"); arrayNew.add(obj); } tagimg.setTagJson(arrayNew.toString()); tagImgService.save(tagimg); } } }