JSONArray and List rotate each other
JSONArray to List
JSONArray array = new JSONArray();
List<T> result = JSONObject.parseArray(array.toJSONString, T.class);
Copy the code
String to List
String str = "";
List<T> result = JSONObject.parseArray(str, T.class);
Copy the code
List to JSONArray
List list = new ArrayList<>();
JSONArray array = JSONObject.parseArray(JSON.toJSONString(list));
Copy the code