-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* A solution to fix #721, and added tests * Replace the test file
- Loading branch information
Showing
2 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
json-path/src/test/java/com/jayway/jsonpath/Issue_721.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.jayway.jsonpath; | ||
|
||
import com.jayway.jsonpath.Configuration; | ||
import com.jayway.jsonpath.DocumentContext; | ||
import com.jayway.jsonpath.JsonPath; | ||
import com.jayway.jsonpath.Option; | ||
import org.junit.Test; | ||
|
||
public class Issue_721 { | ||
|
||
public static final Configuration jsonConf = Configuration.defaultConfiguration().addOptions(Option.SUPPRESS_EXCEPTIONS); | ||
|
||
@Test | ||
public void test_delete_1(){ // originally throws PathNotFoundException | ||
DocumentContext dc = JsonPath.using(jsonConf) | ||
.parse("{\"top\": {\"middle\": null}}") | ||
.delete(JsonPath.compile("$.top.middle.bottom")); | ||
Object ans = dc.read("$"); | ||
//System.out.println(ans); | ||
assert(ans.toString().equals("{top={middle=null}}")); | ||
} | ||
|
||
@Test | ||
public void test_delete_2(){ // originally passed | ||
DocumentContext dc = JsonPath.using(jsonConf) | ||
.parse("[" + | ||
"{\"top\": {\"middle\": null}}," + | ||
"{\"top\": {\"middle\": {} }}," + | ||
"{\"top\": {\"middle\": {bottom: 2} }}," + | ||
"]") | ||
.delete(JsonPath.compile("$[*].top.middle.bottom")); | ||
Object ans = dc.read("$"); | ||
//System.out.println(ans); | ||
assert(ans.toString().equals("[{\"top\":{\"middle\":null}},{\"top\":{\"middle\":{}}},{\"top\":{\"middle\":{}}}]")); | ||
} | ||
} |