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中

<dependency>
    <groupId>cn.hutool</groupId>
    <artifactId>hutool-all</artifactId>
    <version>5.3.9</version>
</dependency>

list转换

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

猜你喜欢

转载自blog.csdn.net/qq_29384639/article/details/107386319