无限循环遍历children字段
private void getChildren(List<JSONObject> arr, JSONArray list) {
for (Object obj : list) {
JSONObject jsonObject = JSONObject.parseObject(obj.toString());
arr.add(jsonObject);
if (jsonObject.get("children") != null) {
getChildren(arr, jsonObject.getJSONArray("children"));
}
}
List childrenList = new ArrayList();
getChildren(childrenList, children);
childrenList.forEach(obj -> {
});