list转json 报错

问题:

Could not write JSON: lazy loading outside command context; nested exception is com.fasterxml.jackson.databind.JsonMappingException: lazy loading outside command context 

解决:

借助hutool工具

pom.xml中


    cn.hutool
    hutool-all
    5.3.9

list转换

cn.hutool.json.JSONArray array = new cn.hutool.json.JSONArray();
        list.forEach(l-> array.add(JSONUtil.parseObj(l, true)));

 

你可能感兴趣的:(java)