Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed issue 537 and added tests (#719)
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
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
29 changes: 29 additions & 0 deletions
29
json-path/src/test/java/com/jayway/jsonpath/Issue_537.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,29 @@ | ||
package com.jayway.jsonpath; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
|
||
public class Issue_537 { | ||
|
||
public static final Configuration jsonConf = Configuration.defaultConfiguration().addOptions(Option.SUPPRESS_EXCEPTIONS); | ||
|
||
@Test | ||
public void test_read(){ // originally passed | ||
Object ans = JsonPath.using(jsonConf).parse("{}").read("missing"); | ||
assert(ans == null); | ||
} | ||
|
||
@Test | ||
public void test_renameKey(){ // originally throws PathNotFoundException | ||
List<Object> ans = JsonPath.using(jsonConf) | ||
.parse("{\"list\":[" + | ||
"{\"data\":{\"old\":1}}," + | ||
"{\"data\":{}}," + | ||
"{\"data\":{\"old\":2}}" + | ||
"]}") | ||
.renameKey("$..data", "old", "new") | ||
.read("$.list"); | ||
assert(ans.toString().equals("[{\"data\":{\"new\":1}},{\"data\":{}},{\"data\":{\"new\":2}}]")); | ||
} | ||
} |