Search in sources :

Example 6 with JsonPointer

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));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Example 7 with JsonPointer

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());
}
Also used : JsonObject(io.vertx.core.json.JsonObject) JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Example 8 with JsonPointer

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));
}
Also used : JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Example 9 with JsonPointer

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());
}
Also used : JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Example 10 with JsonPointer

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));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Aggregations

JsonPointer (io.vertx.core.json.pointer.JsonPointer)24 Test (org.junit.Test)23 JsonObject (io.vertx.core.json.JsonObject)8 JsonArray (io.vertx.core.json.JsonArray)5 ArrayList (java.util.ArrayList)1