use of io.vertx.core.json.JsonArray in project vert.x by eclipse.
the class ConversionHelperTest method testFromJsonObject.
@Test
public void testFromJsonObject() {
JsonObject object = new JsonObject();
object.put("string", "the_string");
object.put("integer", 4);
object.put("boolean", true);
object.put("binary", "hello".getBytes());
object.put("object", new JsonObject().put("nested", 4));
object.put("array", new JsonArray().add(1).add(2).add(3));
Map<String, Object> map = ConversionHelper.fromObject(object);
assertEquals(6, map.size());
assertEquals("the_string", map.get("string"));
assertEquals(4, map.get("integer"));
assertEquals(true, map.get("boolean"));
assertEquals("hello", new String(Base64.getDecoder().decode((String) map.get("binary"))));
assertEquals(Collections.singletonMap("nested", 4), map.get("object"));
assertEquals(Arrays.asList(1, 2, 3), map.get("array"));
}
use of io.vertx.core.json.JsonArray in project vert.x by eclipse.
the class Examples method example3.
public void example3() {
JsonArray array = new JsonArray();
array.add("foo").add(123).add(false);
}
use of io.vertx.core.json.JsonArray in project vert.x by eclipse.
the class HttpServerOptionsConverter method toJson.
public static void toJson(HttpServerOptions obj, JsonObject json) {
json.put("acceptUnmaskedFrames", obj.isAcceptUnmaskedFrames());
if (obj.getAlpnVersions() != null) {
JsonArray array = new JsonArray();
obj.getAlpnVersions().forEach(item -> array.add(item.name()));
json.put("alpnVersions", array);
}
json.put("compressionLevel", obj.getCompressionLevel());
json.put("compressionSupported", obj.isCompressionSupported());
json.put("decompressionSupported", obj.isDecompressionSupported());
json.put("handle100ContinueAutomatically", obj.isHandle100ContinueAutomatically());
json.put("http2ConnectionWindowSize", obj.getHttp2ConnectionWindowSize());
if (obj.getInitialSettings() != null) {
json.put("initialSettings", obj.getInitialSettings().toJson());
}
json.put("maxChunkSize", obj.getMaxChunkSize());
json.put("maxHeaderSize", obj.getMaxHeaderSize());
json.put("maxInitialLineLength", obj.getMaxInitialLineLength());
json.put("maxWebsocketFrameSize", obj.getMaxWebsocketFrameSize());
json.put("maxWebsocketMessageSize", obj.getMaxWebsocketMessageSize());
if (obj.getWebsocketSubProtocols() != null) {
json.put("websocketSubProtocols", obj.getWebsocketSubProtocols());
}
}
use of io.vertx.core.json.JsonArray in project vert.x by eclipse.
the class Examples method example0_2.
public void example0_2() {
String jsonString = "[\"foo\",\"bar\"]";
JsonArray array = new JsonArray(jsonString);
}
use of io.vertx.core.json.JsonArray in project vert.x by eclipse.
the class DeploymentOptionsConverter method toJson.
public static void toJson(DeploymentOptions obj, JsonObject json) {
if (obj.getConfig() != null) {
json.put("config", obj.getConfig());
}
if (obj.getExtraClasspath() != null) {
JsonArray array = new JsonArray();
obj.getExtraClasspath().forEach(item -> array.add(item));
json.put("extraClasspath", array);
}
json.put("ha", obj.isHa());
json.put("instances", obj.getInstances());
if (obj.getIsolatedClasses() != null) {
JsonArray array = new JsonArray();
obj.getIsolatedClasses().forEach(item -> array.add(item));
json.put("isolatedClasses", array);
}
if (obj.getIsolationGroup() != null) {
json.put("isolationGroup", obj.getIsolationGroup());
}
json.put("maxWorkerExecuteTime", obj.getMaxWorkerExecuteTime());
json.put("multiThreaded", obj.isMultiThreaded());
json.put("worker", obj.isWorker());
if (obj.getWorkerPoolName() != null) {
json.put("workerPoolName", obj.getWorkerPoolName());
}
json.put("workerPoolSize", obj.getWorkerPoolSize());
}
Aggregations