/** * Encode the JSON array prettily as a string * * @return the string encoding */ public String encodePrettily() { return Json.encodePrettily(list); }
/** * Encode this JSON object a a string, with whitespace to make the object easier to read by a human, or other * sentient organism. * * @return the pretty string encoding. */ public String encodePrettily() { return Json.encodePrettily(map); }
/** * Encode this JSON object a a string, with whitespace to make the object easier to read by a human, or other * sentient organism. * * @return the pretty string encoding. */ public String encodePrettily() { return Json.encodePrettily(map); }
/** * Encode the JSON array prettily as a string * * @return the string encoding */ public String encodePrettily() { return Json.encodePrettily(list); }
private void getAll(RoutingContext routingContext) { mongo.find(COLLECTION, new JsonObject(), results -> { List<JsonObject> objects = results.result(); List<Whisky> whiskies = objects.stream().map(Whisky::new).collect(Collectors.toList()); routingContext.response() .putHeader("content-type", "application/json; charset=utf-8") .end(Json.encodePrettily(whiskies)); }); }
private void sendReply(RoutingContext context, MailSendResult result) { String varname = readProperty(STORE_RESULT_VARIABLE_PARAMETER, null, false); if (varname == null) { HttpServerResponse response = context.response(); response.putHeader("content-type", "application/json; charset=utf-8").end(Json.encodePrettily(result)); } else { context.put(varname, Json.encodePrettily(result)); context.next(); } }
@Override public Single<Todo> insert(Todo todo) { final String encoded = Json.encodePrettily(todo); return redis.rxHset(Constants.REDIS_TODO_KEY, String.valueOf(todo.getId()), encoded) .map(e -> todo); }
private void getModule(String id, Handler<ExtendedAsyncResult<String>> fut) { moduleManager.get(id, res -> { if (res.failed()) { fut.handle(new Failure<>(res.getType(), res.cause())); return; } String s = Json.encodePrettily(res.result()); fut.handle(new Success<>(s)); }); }
private void listDiscoveryNodes(Handler<ExtendedAsyncResult<String>> fut) { discoveryManager.getNodes(res -> { if (res.failed()) { fut.handle(new Failure<>(res.getType(), res.cause())); return; } final String s = Json.encodePrettily(res.result()); fut.handle(new Success<>(s)); }); }
private void discoveryHealthOne(String srvcId, String instId, Handler<ExtendedAsyncResult<String>> fut) { discoveryManager.health(srvcId, instId, res -> { if (res.failed()) { fut.handle(new Failure<>(res.getType(), res.cause())); return; } final String s = Json.encodePrettily(res.result()); fut.handle(new Success<>(s)); }); }
private void listEnv(Handler<ExtendedAsyncResult<String>> fut) { envManager.get(res -> { if (res.failed()) { fut.handle(new Failure<>(res.getType(), res.cause())); return; } final String s = Json.encodePrettily(res.result()); fut.handle(new Success<>(s)); }); }
private void getEnv(String id, Handler<ExtendedAsyncResult<String>> fut) { envManager.get(id, res -> { if (res.failed()) { fut.handle(new Failure<>(res.getType(), res.cause())); return; } final String s = Json.encodePrettily(res.result()); fut.handle(new Success<>(s)); }); }
private void listTenants(Handler<ExtendedAsyncResult<String>> fut) { tenantManager.list(res -> { if (res.failed()) { fut.handle(new Failure<>(res.getType(), res.cause())); return; } List<TenantDescriptor> tdl = res.result(); String s = Json.encodePrettily(tdl); fut.handle(new Success<>(s)); }); }
private void listDeployments(Handler<ExtendedAsyncResult<String>> fut) { deploymentManager.list(res -> { if (res.failed()) { fut.handle(new Failure<>(res.getType(), res.cause())); return; } final String s = Json.encodePrettily(res.result()); fut.handle(new Success<>(s)); }); }
private void discoveryGetInstId(String srvcId, String instId, Handler<ExtendedAsyncResult<String>> fut) { discoveryManager.get(srvcId, instId, res -> { if (res.failed()) { fut.handle(new Failure<>(res.getType(), res.cause())); return; } final String s = Json.encodePrettily(res.result()); fut.handle(new Success<>(s)); }); }
private void discoveryHealthAll(Handler<ExtendedAsyncResult<String>> fut) { discoveryManager.health(res -> { if (res.failed()) { fut.handle(new Failure<>(res.getType(), res.cause())); return; } final String s = Json.encodePrettily(res.result()); fut.handle(new Success<>(s)); }); }
private void upgradeModulesForTenant(ProxyContext pc, String id, Handler<ExtendedAsyncResult<String>> fut) { TenantInstallOptions options = ModuleUtil.createTenantOptions(pc.getCtx().request()); tenantManager.installUpgradeModules(id, pc, options, null, res -> { if (res.failed()) { fut.handle(new Failure<>(res.getType(), res.cause())); } else { logger.info("installUpgradeModules returns:\n" + Json.encodePrettily(res.result())); fut.handle(new Success<>(Json.encodePrettily(res.result()))); } }); }
private void addOne(RoutingContext routingContext) { final Whisky whisky = Json.decodeValue(routingContext.getBodyAsString(), Whisky.class); mongo.insert(COLLECTION, whisky.toJson(), r -> routingContext.response() .setStatusCode(201) .putHeader("content-type", "application/json; charset=utf-8") .end(Json.encodePrettily(whisky.setId(r.result())))); }
@Override public void handle(RoutingContext context) { jwkSetService.getKeys().subscribe(keys -> context.response() .putHeader(HttpHeaders.CACHE_CONTROL, "no-store") .putHeader(HttpHeaders.PRAGMA, "no-cache") .putHeader(HttpHeaders.CONTENT_TYPE, "application/jwk-set+json; charset=UTF-8") .end(Json.encodePrettily(keys)), error -> context.response().setStatusCode(500).end()); }
@Test(timeout = 3000L) public void testAdd(TestContext context) throws Exception { HttpClient client = vertx.createHttpClient(); Async async = context.async(); Todo todo = new Todo(164, "Test case...", false, 22, "/164"); client.post(PORT, "localhost", "/todos", response -> { context.assertEquals(201, response.statusCode()); client.close(); async.complete(); }).putHeader("content-type", "application/json").end(Json.encodePrettily(todo)); }