webttt

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();
        }

 

分类:

技术点:

相关文章:

  • 2021-12-23
  • 2022-01-02
  • 2022-12-23
  • 2021-12-19
  • 2022-01-02
  • 2022-01-02
  • 2022-12-23
猜你喜欢
  • 2021-08-15
  • 2022-01-02
  • 2021-12-23
  • 2021-12-23
  • 2021-12-26
  • 2021-12-04
  • 2021-11-18
相关资源
相似解决方案