1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

Merge pull request #85 from johnjaylward/JSONPointerTrailingSlash

Test cases for issue described in Issue 410
This commit is contained in:
Sean Leary 2018-03-27 07:45:17 -05:00 committed by GitHub
commit 20d90bfb0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View file

@ -667,7 +667,7 @@ public class JSONObjectTest {
assertTrue("expected 1 top level item", ((Map<?,?>)(JsonPath.read(doc, "$"))).size() == 1);
assertTrue("expected 6 myArray items", ((List<?>)(JsonPath.read(doc, "$.myArray"))).size() == 6);
assertTrue("expected true", Boolean.TRUE.equals(jsonObject.query("/myArray/0")));
assertTrue("expected false", Boolean.FALSE.equals(jsonObject.query("/myArray/1/")));
assertTrue("expected false", Boolean.FALSE.equals(jsonObject.query("/myArray/1")));
assertTrue("expected hello world!", "hello world!".equals(jsonObject.query("/myArray/2")));
assertTrue("expected h\be\tllo w\u1234orld!", "h\be\tllo w\u1234orld!".equals(jsonObject.query("/myArray/3")));
assertTrue("expected 42", Integer.valueOf(42).equals(jsonObject.query("/myArray/4")));

View file

@ -62,6 +62,27 @@ public class JSONPointerTest {
assertSame(document.get(""), query("/"));
}
@Test
public void queryByEmptyKeySubObject() {
assertSame(document.getJSONObject("obj").getJSONObject(""), query("/obj/"));
}
@Test
public void queryByEmptyKeySubObjectSubOject() {
assertSame(
document.getJSONObject("obj").getJSONObject("").get(""),
query("/obj//")
);
}
@Test
public void queryByEmptyKeySubObjectValue() {
assertSame(
document.getJSONObject("obj").getJSONObject("").get("subKey"),
query("/obj//subKey")
);
}
@Test
public void slashEscaping() {
assertSame(document.get("a/b"), query("/a~1b"));

View file

@ -19,6 +19,10 @@
"another/key" : [
"val"
]
},
"" : {
"" : "empty key of an object with an empty key",
"subKey" : "Some other value"
}
}
}