一、依赖Gson:
//list转换为json
Gson gson = new Gson();
List<User> users = new ArrayList<User>();
String str = gson.toJson(users);
//json转换为list
Gson gson = new Gson();
List<User> users = gson.fromJson(str, new TypeToken<List<User>>(){}.getType());
二、依赖fastJson:
//list转换为json
List<User> list = new ArrayList<User>();
String str=JSON.toJSON(list).toString();
//json转换为list
List<User> list = new ArrayList<User>();
list = JSONObject.parseArray(jasonArray, User.class);