maver依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.73</version>
</dependency>
操作实例
User user=this.userService.queryById(1);
//实体类转换为JSON
String json=JSONObject.toJSONString(user);
//JSON转换为实体类
User users=JSON.parseObject(json,User.class);
System.out.println(users.getAddress());
//list转换为JSON
List<String> list=new ArrayList<>();
list.add("11111");
list.add("22222"