本文整理了Java中io.vertx.core.json.Json.encodePrettily()
方法的一些代码示例,展示了Json.encodePrettily()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.encodePrettily()
方法的具体详情如下:
包路径:io.vertx.core.json.Json
类名称:Json
方法名:encodePrettily
[英]Encode a POJO to JSON with pretty indentation, using the underlying Jackson mapper.
[中]使用底层的Jackson映射器,将POJO编码为具有相当缩进的JSON。
代码示例来源:origin: eclipse-vertx/vert.x
/**
* Encode the JSON array prettily as a string
*
* @return the string encoding
*/
public String encodePrettily() {
return Json.encodePrettily(list);
}
代码示例来源:origin: eclipse-vertx/vert.x
/**
* 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);
}
代码示例来源:origin: io.vertx/vertx-core
/**
* 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);
}
代码示例来源:origin: io.vertx/vertx-core
/**
* Encode the JSON array prettily as a string
*
* @return the string encoding
*/
public String encodePrettily() {
return Json.encodePrettily(list);
}
代码示例来源:origin: cescoffier/my-vertx-first-app
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));
});
}
代码示例来源:origin: de.braintags/NetRelayController
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();
}
}
代码示例来源:origin: sczyh30/vertx-blueprint-todo-backend
@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);
}
代码示例来源:origin: folio-org/okapi
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));
});
}
代码示例来源:origin: folio-org/okapi
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));
});
}
代码示例来源:origin: folio-org/okapi
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));
});
}
代码示例来源:origin: folio-org/okapi
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));
});
}
代码示例来源:origin: folio-org/okapi
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));
});
}
代码示例来源:origin: folio-org/okapi
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));
});
}
代码示例来源:origin: folio-org/okapi
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));
});
}
代码示例来源:origin: folio-org/okapi
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));
});
}
代码示例来源:origin: folio-org/okapi
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));
});
}
代码示例来源:origin: folio-org/okapi
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())));
}
});
}
代码示例来源:origin: cescoffier/my-vertx-first-app
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()))));
}
代码示例来源:origin: io.gravitee.am.gateway.handlers/gravitee-am-gateway-handler
@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());
}
代码示例来源:origin: sczyh30/vertx-blueprint-todo-backend
@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));
}
内容来源于网络,如有侵权,请联系作者删除!