Browse Source

How to match "(left instanceof Number && right instanceof Number)" in safeCompare #90

pull/100/merge
Kalle Stenflo 9 years ago
parent
commit
f836244fea
  1. 31
      json-path/src/test/java/com/jayway/jsonpath/old/IssuesTest.java

31
json-path/src/test/java/com/jayway/jsonpath/old/IssuesTest.java

@ -844,4 +844,35 @@ public class IssuesTest extends BaseTest {
Assertions.assertThat(result).isEqualTo("value");
}
@Test
public void issue_90() {
String json = "{\n" +
" \"store\": {\n" +
" \"book\": [\n" +
" {\n" +
" \"price\": \"120\"\n" +
" },\n" +
" {\n" +
" \"price\": 8.95\n" +
" },\n" +
" {\n" +
" \"price\": 12.99\n" +
" },\n" +
" {\n" +
" \"price\": 8.99\n" +
" },\n" +
" {\n" +
" \"price\": 22.99\n" +
" }\n" +
" ]\n" +
" },\n" +
" \"expensive\": 10\n" +
"}";
List<Double> numbers = JsonPath.read(json, "$.store.book[?(@.price <= 90)].price");
assertThat(numbers).containsExactly(8.95D, 12.99D, 8.99D, 22.99D);
}
}

Loading…
Cancel
Save