1、将list集合转为JSON数据字符串
List<User> userinfoList = new ArrayList<User>();
userinfoList .add("hello");
userinfoList .add("world");
String tmp = JSON.toJSONString(userinfoList);
2、将JSON数据转为list集合
String tmp = '[{"name":"六六","sex":"女","Age":20,"hobby":["化妆","美术","甄嬛传","吃鸡"],"normal":true},{"name":"会计","sex":"男","Age":21,"hobby":["吃鸡","吃鸡"],"normal":false}]';
List<User> userinfoList = JSONArray.parseArray(tmp, User.class);
3、遍历集合转为JSON字符串
for (int j = 0; j < userinfoList.size(); j++) {
User userinfo= userinfoList.get(j);
tmp = JsonUtil.toJson(userinfo);
System.out.println(tmp );
}