use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.
the class JsonPointerTest method testJsonObjectQueryingDefaultValue.
@Test
public void testJsonObjectQueryingDefaultValue() {
JsonObject obj = 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/my/friend");
assertEquals(1, pointer.queryJsonOrDefault(obj, 1));
}
use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.
the class JsonPointerTest method testEmptyTracedQuery.
@Test
public void testEmptyTracedQuery() {
JsonPointer pointer = JsonPointer.create().append("child1").append("0").append("child3");
List<Object> traced = pointer.tracedQuery(null, JsonPointerIterator.JSON_ITERATOR);
assertTrue(traced.isEmpty());
}
use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.
the class JsonPointerTest method testNullQueryingRootPointerDefault.
@Test
public void testNullQueryingRootPointerDefault() {
JsonPointer pointer = JsonPointer.create();
assertEquals(1, pointer.queryJsonOrDefault(null, 1));
}
use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.
the class JsonPointerTest method testAppendOtherPointer.
@Test
public void testAppendOtherPointer() {
JsonPointer firstPointer = JsonPointer.fromURI(URI.create("http://example.com/stuff.json#/hello")).append("world");
JsonPointer otherPointer = JsonPointer.fromURI(URI.create("http://example.com/other.json#/francesco"));
firstPointer.append(otherPointer);
assertEquals(URI.create("http://example.com/stuff.json#/hello/world/francesco"), firstPointer.toURI());
}
use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.
the class JsonPointerTest method testJsonObjectQuerying.
@Test
public void testJsonObjectQuerying() {
JsonObject obj = 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");
assertEquals(1, pointer.queryJson(obj));
}
Aggregations