//传入父id
List childList = new ArrayList<>();
treeMenuList(tempMenuList,"5175",childList)
private void treeMenuList(List<JSONObject> menuList, String pid,List<JSONObject> childMenu) {
for (JSONObject mu : menuList) {
//遍历出父id等于参数的id,add进子节点集合
if (pid.equalsIgnoreCase(mu.getString("PID"))) {
//递归遍历下一级
childMenu.add(mu);
treeMenuList(menuList, mu.getString("ID"),childMenu);
}
}
}