本文整理汇总了Java中io.vertx.core.json.JsonObject.put方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.put方法的具体用法?Java JsonObject.put怎么用?Java JsonObject.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Test
public void start(@Mocked Context context) throws Exception {
AtomicInteger count = new AtomicInteger();
ClientPoolManager<HttpClientWithContext> clientMgr = new MockUp<ClientPoolManager<HttpClientWithContext>>() {
@Mock
HttpClientWithContext createClientPool() {
count.incrementAndGet();
return null;
}
}.getMockInstance();
clientVerticle.init(null, context);
JsonObject config = new SimpleJsonObject();
config.put(ClientVerticle.CLIENT_MGR, clientMgr);
new Expectations() {
{
context.config();
result = config;
}
};
clientVerticle.start();
Assert.assertEquals(1, count.get());
}
示例2: toJson
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public static void toJson(PgConnectOptions obj, JsonObject json) {
json.put("cachePreparedStatements", obj.getCachePreparedStatements());
if (obj.getDatabase() != null) {
json.put("database", obj.getDatabase());
}
if (obj.getHost() != null) {
json.put("host", obj.getHost());
}
if (obj.getPassword() != null) {
json.put("password", obj.getPassword());
}
json.put("pipeliningLimit", obj.getPipeliningLimit());
json.put("port", obj.getPort());
if (obj.getUsername() != null) {
json.put("username", obj.getUsername());
}
}
示例3: getConfiguration
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public ConfigurationProvider getConfiguration(String name, Handler<AsyncResult<JsonObject>> resultHandler) {
if (closed) {
resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
return this;
}
JsonObject _json = new JsonObject();
_json.put("name", name);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "getConfiguration");
_vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
if (res.failed()) {
resultHandler.handle(Future.failedFuture(res.cause()));
} else {
resultHandler.handle(Future.succeededFuture(res.result().body()));
}
});
return this;
}
示例4: rootHandler
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
* Handler for the /api endpoint, listing out routes and loaded verticles
*
* @param ctx
*/
private void rootHandler(final RoutingContext ctx) {
ctx.response().putHeader(Constants.CONTENT_HEADER, Constants.CONTENT_TYPE_JSON);
final JsonObject result = new JsonObject().put("RunningSince", Utils.getDateString(this.startDate));
final JsonObject routeObject = new JsonObject();
for (final Route r : this.router.getRoutes()) {
final String p = r.getPath();
if (p != null) {
routeObject.put(p, String.valueOf(r));
}
}
result.put("Routes", routeObject);
final JsonArray verticleArray = new JsonArray(this.loadedVerticles);
result.put("Verticles", verticleArray);
ctx.response().end(result.encodePrettily());
}
示例5: send
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public MailService send(MailMessage message, Handler<AsyncResult<MailResult>> resultHandler) {
if (closed) {
resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
return this;
}
JsonObject _json = new JsonObject();
_json.put("message", message == null ? null : message.toJson());
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "send");
_vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
if (res.failed()) {
resultHandler.handle(Future.failedFuture(res.cause()));
} else {
resultHandler.handle(Future.succeededFuture(res.result().body() == null ? null : new MailResult(res.result().body())));
}
});
return this;
}
示例6: toJSON
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public JsonObject toJSON() {
JsonObject json = new JsonObject();
//add header information
json.put("event", this.event);
json.put("messageID", this.uuid.toString());
//add message body
json.put("data", this.data);
if (!this.ssid.isEmpty()) {
json.put("ssid", this.ssid);
}
return json;
}
示例7: encodeToWire
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public void encodeToWire(Buffer buffer, AuthInfo s) {
// Easiest ways is using JSON object
JsonObject jsonToEncode = new JsonObject();
jsonToEncode.put("serverName", s.serverName);
jsonToEncode.put("sessionToken", s.sessionToken);
// Encode object to string
String jsonToStr = jsonToEncode.encode();
// Length of JSON: is NOT characters count
int length = jsonToStr.getBytes().length;
// Write data into given buffer
buffer.appendInt(length);
buffer.appendString(jsonToStr);
}
示例8: toJson
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public static void toJson(CoreNLPClientOptions obj, JsonObject json) {
if (obj.getHost() != null) {
json.put("host", obj.getHost());
}
if (obj.getPassword() != null) {
json.put("password", obj.getPassword());
}
json.put("port", obj.getPort());
json.put("ssl", obj.isSsl());
if (obj.getSslKey() != null) {
json.put("sslKey", obj.getSslKey());
}
if (obj.getUsername() != null) {
json.put("username", obj.getUsername());
}
}
示例9: reformatJsonListResponse
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public static JsonObject reformatJsonListResponse(ListResponse<?> result) {
List<?> data = result.getData();
JsonArray array = null;
if (data != null) {
array = reformatJsonList(data);
}
result.setData(null);
JsonObject jsonObject = reformatJsonObject(JsonObject.mapFrom(result), CaseConversion.CAMEL_TO_SNAKE, false);
if (array != null) {
jsonObject.put("data", array);
}
return jsonObject;
}
示例10: toJson
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public JsonObject toJson() {
final JsonObject data = new JsonObject();
data.put("name", this.name);
final JsonObject config = null == this.options ? new JsonObject() : this.options.copy();
config.put("host", this.host);
config.put("port", this.port);
data.put("config", config);
return data;
}
示例11: principal
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public JsonObject principal() {
JsonObject json = new JsonObject();
json.put("role", role);
return json;
}
示例12: toJson
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public static void toJson(PgNotification obj, JsonObject json) {
if (obj.getChannel() != null) {
json.put("channel", obj.getChannel());
}
if (obj.getPayload() != null) {
json.put("payload", obj.getPayload());
}
json.put("processId", obj.getProcessId());
}
示例13: apiResponse
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private void apiResponse(RoutingContext context, int statusCode, String jsonField, Object jsonData) {
context.response().setStatusCode(statusCode);
context.response().putHeader("Content-Type", "application/json");
JsonObject wrapped = new JsonObject().put("success", true);
if (jsonField != null && jsonData != null) wrapped.put(jsonField, jsonData);
context.response().end(wrapped.encode());
}
示例14: getDefaults
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private JsonObject getDefaults() {
final JsonObject defaults = new JsonObject();
defaults.put("period", 5000);
defaults.put("maxPeriod", 5000);
defaults.put("attempts", 3);
return defaults;
}
示例15: apiResponse
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private void apiResponse(RoutingContext context, int statusCode, String jsonField, Object jsonData) {
context.response().setStatusCode(statusCode);
context.response().putHeader("Content-Type", "application/json");
JsonObject wrapped = new JsonObject().put("success", true);
if (jsonField != null && jsonData != null) {
wrapped.put(jsonField, jsonData);
}
context.response().end(wrapped.encode());
}