JsonPath仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
955 B

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}}]"));
}
}