对接口返回的jsonarray 数据进行过滤

图片说明

            接口返回一组 jsonarray的数据(每个jsonobject的key数量都是一样的) ,现在有一个存储了 需要的展示的key的list       从返回的jsonarray中取出和list中的key匹配的数据 重新返回 jsonarray  (过滤操作)


            除了嵌套循环  有没有其他的方式  Java8的  stream  可以吗?

这个问题自己查阅 改造了下 搞定了 jsonArray 转成map类型的list 通过stream 判断key值 是否匹配 ture 则保留 false stream会通过filter过滤
List> mapListJson = (List)jsonArray;
List> mapListJson = (List)AllFiledheadlist;
for(int i=0;i Map map =mapListJson.get(i).entrySet().stream().filter((e) -> checkValue(e.getKey(),permisson_filed)).collect(Collectors.toMap((e) -> (String) e.getKey(), (e) -> e.getValue()));
fieldList.add(map);
}

private static boolean checkValue(Object object,ArrayList permisson_filed){
    System.out.println(object);
    if (permisson_filed.contains(object)) {
        return true;
    }else{
        return false;
    }
}

https://blog.csdn.net/zone_four/article/details/78355015