use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.
the class JsonPointerTest method testParsing.
@Test
public void testParsing() {
JsonPointer pointer = JsonPointer.from("/hello/world");
assertEquals("/hello/world", pointer.toString());
}
use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.
the class JsonPointerTest method testTracedQuery.
@Test
public void testTracedQuery() {
JsonObject child2 = new JsonObject().put("child3", 1);
JsonArray child1 = new JsonArray().add(child2);
JsonObject root = new JsonObject().put("child1", child1);
JsonPointer pointer = JsonPointer.create().append("child1").append("0").append("child3");
List<Object> traced = pointer.tracedQuery(root, JsonPointerIterator.JSON_ITERATOR);
assertEquals(4, traced.size());
assertSame(root, traced.get(0));
assertSame(child1, traced.get(1));
assertSame(child2, traced.get(2));
assertEquals(1, traced.get(3));
}
use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.
the class JsonPointerExamples method example1Pointers.
public void example1Pointers() {
// Build a pointer from a string
JsonPointer pointer1 = JsonPointer.from("/hello/world");
// Build a pointer manually
JsonPointer pointer2 = JsonPointer.create().append("hello").append("world");
}
use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.
the class JsonPointerTest method testIsParent.
@Test
public void testIsParent() {
JsonPointer parent = JsonPointer.fromURI(URI.create("yaml/valid/refs/Circular.yaml#/properties"));
JsonPointer child = JsonPointer.fromURI(URI.create("yaml/valid/refs/Circular.yaml#/properties/parent"));
assertTrue(parent.isParent(child));
assertFalse(child.isParent(parent));
}
use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.
the class JsonPointerTest method testWrongUsageOfDashForQuerying.
@Test
public void testWrongUsageOfDashForQuerying() {
JsonArray array = new JsonArray();
array.add(new JsonObject().put("hello", new JsonObject().put("world", 2).put("worl", "wrong")).put("helo", new JsonObject().put("world", "wrong").put("worl", "wrong")));
array.add(new JsonObject().put("hello", new JsonObject().put("world", 1).put("worl", "wrong")).put("helo", new JsonObject().put("world", "wrong").put("worl", "wrong")));
JsonPointer pointer = JsonPointer.from("/-/hello/world");
assertNull(pointer.queryJson(array));
}
Aggregations