如何将List列表转化为JSON
将List转化为json
JSONArray array = JSONArray.fromObject(list);
用这种方法需要导入import net.sf.json.JSONArray;
如何导入import net.sf.json.JSONArray;
需要在xml里面导入下面内容
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>