File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
main/java/com/jayway/jsonpath/internal/filter
test/java/com/jayway/jsonpath Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -801,7 +801,7 @@ public PathNode asExistsCheck(boolean shouldExist) {
801801
802802 @ Override
803803 public String toString () {
804- return path .toString ();
804+ return existsCheck && ! shouldExist ? Utils . concat ( "!" , path . toString ()) : path .toString ();
805805 }
806806
807807 public ValueNode evaluate (Predicate .PredicateContext ctx ) {
Original file line number Diff line number Diff line change @@ -84,6 +84,15 @@ public void invalid_filters_does_not_compile() {
8484 assertInvalidPathException ("[?(!'foo')]" );
8585 }
8686
87+ @ Test
88+ // issue #178
89+ public void compile_and_serialize_not_exists_filter (){
90+ Filter compiled = compile ("[?(!@.foo)]" );
91+ String serialized = compiled .toString ();
92+ assertThat (serialized ).isEqualTo ("[?(!@['foo'])]" );
93+ }
94+
95+
8796
8897 private void assertInvalidPathException (String filter ){
8998 try {
You can’t perform that action at this time.
0 commit comments