com.jayway.jsonpath.Criteria Java Examples

The following examples show how to use com.jayway.jsonpath.Criteria. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonPathExample.java    From levelup-java-examples with Apache License 2.0 6 votes vote down vote up
/**
 * 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());
}
 
Example #2
Source File: OperationIntegrationTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenJsonPathWithFilterPredicate_whenReading_thenCorrect() {
    Filter expensiveFilter = Filter.filter(Criteria.where("price")
        .gt(20.00));
    List<Map<String, Object>> expensive = JsonPath.parse(jsonDataSourceString)
        .read("$['book'][?]", expensiveFilter);
    predicateUsageAssertionHelper(expensive);
}