2016-11-05 63 views
0

我想通过一个字符串数组循环和每个字符串添加到JsonPath过滤对象:建立在一个循环中的过滤器,JSONPath

Filter f = filter(); // ERROR 
for (int j = 0; j < in_paths.size(); j++) 
{ 
     f = f.and(where(in_paths[j]).exists(true)); 
} 

用这种方法唯一的问题是,我似乎无法创建一个“空”过滤器。有谁知道这是否可能?如果没有,有人可以提供替代方案吗?

回答

0

初始过滤器可以用来检查文档根目录是否存在。

Filter f = filter(where("$").exists(true)); 
for (int j = 0; j < in_paths.size(); j++) 
{ 
     f = f.and(where(in_paths[j]).exists(true)); 
}