java 给json框打上分类名称
public void import9(){ TagImgFilter filter = new TagImgFilter();//更改的集合 filter.setEq_orgId("c1fa7ba875fa4c9a899e2787eb79e802"); filter.setEq_setId("d5e8f01a2e6649cf877eacda8ceb6ff1"); filter.setEq_typeId("ff4dfd4ba7d949958b3d630a90fcca75"); 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); TagType tagType = tagTypeService.getById(tagimg.getTypeId()); 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); System.out.println(obj); obj.put("classname", tagType.getName()); System.out.println("-----------------"); System.out.println(obj); arrayNew.add(obj); } tagimg.setTagJson(arrayNew.toString()); tagImgService.save(tagimg); } } }