java中LIst转换成Json
List转换成json串
public String getNameListByID(Long Id) { List<Name> nameLists= nameService.selectNameById(Id);//获取List if(null == nameLists){ return null; } JSONArray jsonArray = new JSONArray(); for(Name nameList : nameLists){ JSONObject jo = new JSONObject(); jo.put("NameCode", nameList.getNameCode()); jo.put("Name", nameList.getName()); jsonArray.add(jo); } return jsonArray.toString(); }
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

更多精彩