• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Filter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.jayway.jsonpath.Filter的典型用法代码示例。如果您正苦于以下问题:Java Filter类的具体用法?Java Filter怎么用?Java Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Filter类属于com.jayway.jsonpath包,在下文中一共展示了Filter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: issues_by_state_and_number

import com.jayway.jsonpath.Filter; //导入依赖的package包/类
/**
 * Issues that are open and have a number >= 30
 */
@Test
public void issues_by_state_and_number () {
	
	Filter<?> filter = Filter.filter(
			Criteria.where("state")
				.is("open")
				.and("number")
				.gte(30));

	List<Object> issuesByLabelAndAuthor = JsonPath.read(githubIssues, "$.[?]", filter);
	
	logger.info(issuesByLabelAndAuthor);

	assertEquals(1, issuesByLabelAndAuthor.size());
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:19,代码来源:JsonPathExample.java


示例2: testJsonPathManual

import com.jayway.jsonpath.Filter; //导入依赖的package包/类
@Test
public void testJsonPathManual() throws URISyntaxException, IOException {
	document = Configuration.defaultConfiguration()
			  .jsonProvider().parse(FileUtils.readContent("general/book.json"));

	List<String> authors = JsonPath.read(document, "$.store.book[*].author");
	assertEquals(
			  Arrays.asList("Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien"),
			  authors);

	assertEquals("Nigel Rees", JsonPath.read(document, "$.store.book[0].author"));
	assertEquals("Evelyn Waugh", JsonPath.read(document, "$.store.book[1].author"));

	List<Map<String, Object>> expensiveBooks = JsonPath
			  .using(Configuration.defaultConfiguration())
			  .parse(FileUtils.readContent("general/book.json"))
			  .read("$.store.book[?(@.price > 10)]", List.class);
	assertEquals(2, expensiveBooks.size());

	String json = "{\"date_as_long\" : 1411455611975}";
	Date date = JsonPath.parse(json).read("$['date_as_long']", Date.class);
	assertEquals("23 Sep 2014 07:00:11 GMT", date.toGMTString());

	List<Map<String, Object>> books = JsonPath.read(document, "$.store.book[?(@.price < 10)]");
	assertEquals(2, books.size());

	Filter cheapFictionFilter = filter(where("category").is("fiction").and("price").lte(10D));

	books = JsonPath.read(document, "$.store.book[?]", cheapFictionFilter);
	assertEquals(1, books.size());

	Filter fooOrBar = filter(where("category").exists(true)).or(where("price").exists(true));
	books = JsonPath.read(document, "$.store.book[?]", fooOrBar);
	assertEquals(4, books.size());

	Filter fooAndBar = filter(where("category").exists(true))
	                   .and(where("price").exists(true));
	books = JsonPath.read(document, "$.store.book[?]", fooAndBar);
	assertEquals(4, books.size());
}
 
开发者ID:pkiraly,项目名称:metadata-qa-api,代码行数:41,代码来源:JsonPathsTest.java


示例3: testOr

import com.jayway.jsonpath.Filter; //导入依赖的package包/类
@Test
public void testOr() throws URISyntaxException, IOException {
	document = Configuration.defaultConfiguration()
			  .jsonProvider().parse(FileUtils.readContent("general/test.json"));
	String providerProxy = "$.['ore:Proxy'][?(@['edm:europeanaProxy'][0] == 'false')][?]";

	String idPath = "$.identifier";
	String dataProviderPath = "$.['ore:Aggregation'][0]['edm:dataProvider'][0]";
	String datasetPath = "$.sets[0]";

	Filter fooOrBar = filter(where("identifier").exists(true)).or(Criteria.where("sets").exists(true));
	Map<String, Object> books = JsonPath.read(document, "$", fooOrBar);
	assertEquals(9, books.size());

	Filter titleOrDescription = filter(where("dc:title").exists(true)).or(Criteria.where("dc:description").exists(true));
	JSONArray proxy = JsonPath.read(document, providerProxy, titleOrDescription);
	assertEquals(1, proxy.size());

	Filter titleAndDescription = filter(where("dc:title").exists(true)).and(Criteria.where("dc:description").exists(true));
	proxy = JsonPath.read(document, providerProxy, titleAndDescription);
	assertEquals(0, proxy.size());

	proxy = JsonPath.read(document, providerProxy, filter(where("['dc:title1']").exists(true)));
	assertEquals(0, proxy.size());

	titleOrDescription = filter(where("['dc:title1']").exists(true)).and(Criteria.where("['dc:description']").exists(true));
	proxy = JsonPath.read(document, providerProxy, titleOrDescription);
	assertEquals(0, proxy.size());
}
 
开发者ID:pkiraly,项目名称:metadata-qa-api,代码行数:30,代码来源:JsonPathsTest.java


示例4: exists

import com.jayway.jsonpath.Filter; //导入依赖的package包/类
/**
 * Verifies the existence of a property within a JSON document.
 * 
 * @param jsonPath
 *            The jsonPath to the requested property.
 * @param filters
 *            Optional filters that allow to select certain items for lists.
 * 
 * @return <b>true</b> if the path to the property exists, <b>false</b> if
 *         not.
 */
public boolean exists( String jsonPath, Filter<?>... filters )
{
    try
    {
        return get( jsonPath, filters ) == null ? false : true;
    }
    catch ( PathNotFoundException e )
    {
        return false;
    }
}
 
开发者ID:Xceptance,项目名称:XRT-Xceptance-REST-Test,代码行数:23,代码来源:JSON.java


示例5: compile

import com.jayway.jsonpath.Filter; //导入依赖的package包/类
public static Filter compile(String filterString) {
    FilterCompiler compiler = new FilterCompiler(filterString);
    return new CompiledFilter(compiler.compile());
}
 
开发者ID:osswangxining,项目名称:another-rule-based-analytics-on-spark,代码行数:5,代码来源:FilterCompiler.java


示例6: JsonPathSelector

import com.jayway.jsonpath.Filter; //导入依赖的package包/类
public JsonPathSelector(ObjectMapper mapper, String jsonPath, Filter... filters) {
  super(JsonPath.compile(jsonPath, filters));
  this.mapper = mapper;
  this.jsonPathConfig = Configuration.builder().jsonProvider(new Jackson2JsonProvider(mapper)).build();
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:6,代码来源:JsonPathSelector.java


示例7: J

import com.jayway.jsonpath.Filter; //导入依赖的package包/类
public static Selector J(String jsonPath, Filter... filters) {
  return jsonPathSelector(jsonPath, filters);
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:4,代码来源:JsonPathSelector.java


示例8: jsonPathSelector

import com.jayway.jsonpath.Filter; //导入依赖的package包/类
public static Selector jsonPathSelector(String jsonPath, Filter... filters) {
  return new JsonPathSelector(jsonPath, filters);
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:4,代码来源:JsonPathSelector.java


示例9: get

import com.jayway.jsonpath.Filter; //导入依赖的package包/类
/**
 * Gets a property of the JSON via a specified jsonPath and an optional
 * filter. This method uses the
 * {@link JsonPath#read(String, String, Filter...)} method. On details how
 * to use the filter please see <a
 * href="http://code.google.com/p/json-path">JSON-Path documentation</a>.
 * 
 * @param <T>
 *            Auto calculated return type.
 * @param jsonPath
 *            The jsonPath to the requested property.
 * @param filters
 *            Optional filters that allow to select certain items for lists.
 * 
 * @return The value of the requested JSON property.
 */
public <T> T get( String jsonPath, Filter<?>... filters )
{
    return JsonPath.read( this.toString(), jsonPath, filters );
}
 
开发者ID:Xceptance,项目名称:XRT-Xceptance-REST-Test,代码行数:21,代码来源:JSON.java



注:本文中的com.jayway.jsonpath.Filter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NullListener类代码示例发布时间:2022-05-22
下一篇:
Java BERSet类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap