Browse Source

Merge pull request #330 from jochenberger/patch-1

Fix JSON detection
pull/331/head
kallestenflo 8 years ago committed by GitHub
parent
commit
46934460f4
  1. 2
      json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNode.java
  2. 7
      json-path/src/test/java/com/jayway/jsonpath/FilterTest.java

2
json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNode.java

@ -154,7 +154,7 @@ public abstract class ValueNode {
if ((c0 == '[' && c1 == ']') || (c0 == '{' && c1 == '}')){
try {
Configuration.defaultConfiguration().jsonProvider().parse(str);
return false;
return true;
} catch(Exception e){
return false;
}

7
json-path/src/test/java/com/jayway/jsonpath/FilterTest.java

@ -89,6 +89,13 @@ public class FilterTest extends BaseTest {
assertThat(filter(where("string-key").eq(null)).apply(createPredicateContext(json))).isEqualTo(false);
}
@Test
public void arr_eq_evals() {
assertThat(filter(where("arr-empty").eq("[]")).apply(createPredicateContext(json))).isEqualTo(true);
assertThat(filter(where("int-arr").eq("[0,1,2,3,4]")).apply(createPredicateContext(json))).isEqualTo(true);
assertThat(filter(where("int-arr").eq("[0,1,2,3]")).apply(createPredicateContext(json))).isEqualTo(false);
assertThat(filter(where("int-arr").eq("[0,1,2,3,4,5]")).apply(createPredicateContext(json))).isEqualTo(false);
}
//----------------------------------------------------------------------------
//
// NE

Loading…
Cancel
Save