JSONArray 与 List 互转

List 转 JSONArray

// 通过JSONPath获取其中数据,也可以说自己生成的List
 List<JSONObject> caseList =  JsonPath.read(resStr, "$.result.case");
 // 转换为JSONArray
 JSONArray cases = JSONArray.parseArray(JSON.toJSONString(caseList));

JSONArray 转 List

JSONArray array = new JSONArray();
List<T> list = JSONObject.parseArray(array.toJSONString(), T.class);

String 转 List

String str = "";
List<T> list = JSONObject.parseArray(str, T.class);
原文地址:https://www.cnblogs.com/eternityz/p/12239574.html