JAVA-20277 GitHub Issue: Regarding article Introduction to JsonPath (#13939)
This commit is contained in:
parent
761eecbcd6
commit
386e3b2816
@ -1,9 +1,11 @@
|
|||||||
package com.baeldung.jsonpath.introduction;
|
package com.baeldung.jsonpath.introduction;
|
||||||
|
|
||||||
import com.jayway.jsonpath.Configuration;
|
import com.jayway.jsonpath.Configuration;
|
||||||
|
import com.jayway.jsonpath.Criteria;
|
||||||
import com.jayway.jsonpath.DocumentContext;
|
import com.jayway.jsonpath.DocumentContext;
|
||||||
import com.jayway.jsonpath.JsonPath;
|
import com.jayway.jsonpath.JsonPath;
|
||||||
import com.jayway.jsonpath.Option;
|
import com.jayway.jsonpath.Option;
|
||||||
|
import com.jayway.jsonpath.Filter;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -98,4 +100,14 @@ public class ServiceIntegrationTest {
|
|||||||
|
|
||||||
assertEquals("Spectre", title);
|
assertEquals("Spectre", title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenJsonPathWithFilterPredicate_whenReadingRootNode_thenCorrect() {
|
||||||
|
Filter expensiveFilter = Filter.filter(Criteria.where("director")
|
||||||
|
.contains("Sam Mendes"));
|
||||||
|
List<Map<String, Object>> predicate = JsonPath.parse(jsonString)
|
||||||
|
.read("$[?]['director']", expensiveFilter);
|
||||||
|
assertEquals(predicate.size(), 2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user