当前位置: 首页>>代码示例>>Java>>正文


Java JsonObject.put方法代码示例

本文整理汇总了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());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:TestClientVerticle.java

示例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());
  }
}
 
开发者ID:vietj,项目名称:reactive-pg-client,代码行数:18,代码来源:PgConnectOptionsConverter.java

示例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;
}
 
开发者ID:pflima92,项目名称:jspare-vertx-ms-blueprint,代码行数:19,代码来源:ConfigurationProviderVertxEBProxy.java

示例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());
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:21,代码来源:ApplicationStarter.java

示例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;
}
 
开发者ID:pflima92,项目名称:jspare-vertx-ms-blueprint,代码行数:19,代码来源:MailServiceVertxEBProxy.java

示例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;
}
 
开发者ID:open-erp-systems,项目名称:erp-frontend,代码行数:18,代码来源:Message.java

示例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);
	
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:19,代码来源:AuthInfoCodec.java

示例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());
  }
}
 
开发者ID:shikeio,项目名称:vertx-corenlp-client,代码行数:17,代码来源:CoreNLPClientOptionsConverter.java

示例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;
}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:14,代码来源:Serializer.java

示例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;
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:10,代码来源:ServidorOptions.java

示例11: principal

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public JsonObject principal() {

	JsonObject json = new JsonObject();
	json.put("role", role);
	return json;
}
 
开发者ID:zandero,项目名称:rest.vertx,代码行数:8,代码来源:SimulatedUser.java

示例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());
}
 
开发者ID:vietj,项目名称:reactive-pg-client,代码行数:10,代码来源:PgNotificationConverter.java

示例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());
}
 
开发者ID:dreamzyh,项目名称:vertx-guide-for-java-devs_chinese,代码行数:8,代码来源:HttpServerVerticle.java

示例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;
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:8,代码来源:FeignDepot.java

示例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());
}
 
开发者ID:dreamzyh,项目名称:vertx-guide-for-java-devs_chinese,代码行数:10,代码来源:HttpServerVerticle.java


注:本文中的io.vertx.core.json.JsonObject.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。