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


Java JsonObject.getJsonArray方法代码示例

本文整理汇总了Java中io.vertx.core.json.JsonObject.getJsonArray方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.getJsonArray方法的具体用法?Java JsonObject.getJsonArray怎么用?Java JsonObject.getJsonArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vertx.core.json.JsonObject的用法示例。


在下文中一共展示了JsonObject.getJsonArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromJson

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

	super.fromJson(json);

	JsonArray array = json.getJsonArray(TRACKERS);

	if (array != null && array.size() > 0) {
		array.forEach(object -> {
			if (object instanceof JsonObject) {
				JsonObject tracker = (JsonObject) object;

				String host = tracker.getString(HOST, "");
				int port = tracker.getInteger(PORT, -1);

				if (!host.isEmpty() && port != -1) {
					trackers.add(SocketAddress.inetSocketAddress(port, host));
				}
			}
		});
	}
	
	return this;
}
 
开发者ID:gengteng,项目名称:vertx-fastdfs-client,代码行数:25,代码来源:FdfsClientOptions.java

示例2: processInit

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private Handler<Message<JsonObject>> processInit() {
    return msg -> {
    	try{
         JsonObject payload = msg.body();
         JsonArray buys = payload.getJsonArray("Buys");
         
for(int i = 0; i<buys.size();i++){
	orderBook.getBuyOrders().put(buys.getJsonObject(i).getDouble("Rate"), buys.getJsonObject(i).getDouble("Quantity"));
}
JsonArray sells = payload.getJsonArray("Sells");
for(int i = 0; i<sells.size();i++){
	orderBook.getSellOrders().put(sells.getJsonObject(i).getDouble("Rate"), sells.getJsonObject(i).getDouble("Quantity"));
}
vertx.eventBus().publish(MessageDefinitions.ORDERBOOK_READY+":"+tradingPair, "ready");
    	} catch(Exception e){
    		e.printStackTrace();
    		System.out.println("Failed setting up Order Book");
    	}
    };
}
 
开发者ID:AlxGDev,项目名称:BittrexGatherer,代码行数:21,代码来源:BittrexOrderBookVerticle.java

示例3: configureBridgeOptions

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private BridgeOptions configureBridgeOptions(JsonObject config) {
    BridgeOptions bridgeOptions = new BridgeOptions();
    JsonObject addresses=config.getJsonObject(ADDRESSES);

    JsonArray outbounds=addresses.getJsonArray(OUTBOUND);
    JsonArray inbounds=addresses.getJsonArray(INBOUND);

    outbounds.forEach(o-> addOutboundPermitted(bridgeOptions, (JsonObject) o));
    inbounds.forEach(i-> addInboundPermitted(bridgeOptions, (JsonObject) i));
    return bridgeOptions;
}
 
开发者ID:GwtDomino,项目名称:domino-event-bus,代码行数:12,代码来源:VertxConfigSockJsConfigurator.java

示例4: extractGroupInfo

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
 * 
 * @param msg
 *            the group details in json format to be parsed
 * @return the group id of the group contained in the message
 *         -2 if this message has already been received
 */
private int extractGroupInfo(String msg) {
    TreeSet<Node> set = new TreeSet<>();
    Group group = null;
    JsonObject obj = new JsonObject(msg);
    String prime = obj.getString(Constants.PRIME);
    String generator = obj.getString(Constants.GENERATOR);
    JsonArray members = obj.getJsonArray(Constants.MEMBERS);
    Iterator<?> iter = members.iterator();
    while (iter.hasNext()) {
        JsonObject member = (JsonObject) iter.next();
        String ip = member.getString(Constants.IP);
        String port = member.getString(Constants.PORT);
        Node n = new Node(ip, port);
        set.add(n);
    }
    group = new Group(generator, prime, set);
    if (stateMappings.containsKey(group.getGroupId()) && !stateMappings.get(group.getGroupId()).isDone())
        return -2; // message received twice
    group.setGenerator(new BigInteger(generator));
    group.setPrime(new BigInteger(prime));
    groupMappings.put(group.getGroupId(), group);
    stateMappings.put(group.getGroupId(), new ExchangeState(group.getGroupId(), group.getGenerator()));
    return group.getGroupId();
}
 
开发者ID:maxamel,项目名称:GDH,代码行数:32,代码来源:JsonMessageParser.java

示例5: insertSeasonViews

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public Future<JsonObject> insertSeasonViews(String username, JsonObject seasonData, String seriesId) { // TODO: 18/05/2017 test
    StringBuilder query = new StringBuilder(SQL_INSERT_SEASON);
    JsonArray episodes = seasonData.getJsonArray("episodes");
    JsonArray values = new JsonArray();
    ifFalse(episodes.isEmpty(), () -> {
        episodes.stream()
                .map(obj -> (JsonObject) obj)
                .peek(json -> query.append(" (?, ?, ?, ?, ?),"))
                .forEach(json -> values
                        .add(username)
                        .add(seriesId)
                        .add(json.getInteger("id"))
                        .add(seasonData.getString("_id"))
                        .add(currentTimeMillis()));
        query.deleteCharAt(query.length() - 1);
    });
    return updateOrInsert(query.toString(), values);
}
 
开发者ID:kristenkotkas,项目名称:moviediary,代码行数:20,代码来源:DatabaseServiceImpl.java

示例6: visit

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public ConcurrentMap<Integer, String> visit(final String... key)
        throws ZeroException {
    // 1. Must be the first line, fixed position.
    Ensurer.eqLength(getClass(), 1, (Object[]) key);
    // 2. Visit the node for server, http
    final JsonObject data = this.NODE.read();

    Fn.flingZero(null == data || !data.containsKey(KEY), getLogger(),
            ServerConfigException.class,
            getClass(), null == data ? null : data.encode());
    // 3. Extract names.
    final JsonArray raw = data.getJsonArray(KEY);
    this.type = ServerType.valueOf(key[Values.IDX]);
    return extract(raw);
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:17,代码来源:NamesVisitor.java

示例7: syncBatchMaterial

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
 * 获取素材
 * @param mediaType 素材类型
 * @param offset 开始位置
 * @param count 获取数量
 * @return
 */
public static Material syncBatchMaterial(MediaType mediaType, Integer offset, Integer count, Account mpAccount){
	String accessToken = getAccessToken(mpAccount);
	String url = WxApi.getBatchMaterialUrl(accessToken);
	JsonObject bodyObj = new JsonObject();
	bodyObj.put("type", mediaType.toString());
	bodyObj.put("offset", offset);
	bodyObj.put("count", count);
	String body = bodyObj.toString();
	try {
		JsonObject jsonObj = WxApi.httpsRequest(url, "POST", body);
		if (jsonObj.containsKey("errcode")) {//获取素材失败
			System.out.println(ErrCode.errMsg(jsonObj.getInteger("errcode")));
			return null;
		}else{
			Material material = new Material();
			material.setTotalCount(jsonObj.getInteger("total_count"));
			material.setItemCount(jsonObj.getInteger("item_count"));
			JsonArray arr = jsonObj.getJsonArray("item");
			if(arr != null && arr.size() > 0){
				List<MaterialItem> itemList = new ArrayList<MaterialItem>();
				for(int i = 0; i < arr.size(); i++){
					JsonObject item = arr.getJsonObject(i);
					MaterialItem materialItem = new MaterialItem();
					materialItem.setMediaId(item.getString("media_id"));
					materialItem.setUpdateTime(item.getLong("update_time")*1000L);
					if(item.containsKey("content")){//mediaType=news (图文消息)
						JsonArray articles = item.getJsonObject("content").getJsonArray("news_item");
						List<MaterialArticle> newsItems = new ArrayList<MaterialArticle>();
						for(int j = 0; j < articles.size(); j++){
							JsonObject article = articles.getJsonObject(j);
							MaterialArticle ma = new MaterialArticle();
							ma.setTitle(article.getString("title"));
							ma.setThumb_media_id(article.getString("thumb_media_id"));
							ma.setShow_cover_pic(article.getString("show_cover_pic"));
							ma.setAuthor(article.getString("author"));
							ma.setContent_source_url(article.getString("content_source_url"));
							ma.setContent(article.getString("content"));
							ma.setUrl(article.getString("url"));
							newsItems.add(ma);
						}
						materialItem.setNewsItems(newsItems);
					}else{
						materialItem.setName(item.getString("name"));
						materialItem.setUrl(item.getString("url"));
					}
					itemList.add(materialItem);
				}
				material.setItems(itemList);
			}
			return material;
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:Leibnizhu,项目名称:AlipayWechatPlatform,代码行数:64,代码来源:WxApiClient.java

示例8: start

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

    JsonObject config = config();
    JsonArray urls = config.getJsonArray(CommonConstants.HE_RSS_URL_LIST_ENV);
    urls.iterator().forEachRemaining(o -> {
        String url = (String) o;
        HEEndpointModel model = new HEEndpointModel();
        String label = stripAndFormatSuffix(url);
        model.setLabel(label);
        model.setUrl(url);
        model.setPollingPeriod(30000);
        model.setActive(false);
        endpoints.put(label, model);
    });

    Router router = Router.router(vertx);

    HealthCheckHandler healthCheckHandler = HealthCheckHandler.create(vertx).register("server-online",
            fut -> fut.complete(online ? Status.OK() : Status.KO()));

    router.get("/api/health/readiness").handler(rc -> rc.response().end(CommonConstants.OK));
    router.get("/api/health/liveness").handler(healthCheckHandler);
    router.get("/api/get/count/:term").handler(this::getIncidentCountsForType);
    router.get("/api/get/count/:term/:id").handler(this::getIncidentCountsForTypeWithId);
    router.get("/api/get/detail/:term/:id").handler(this::getIncidentDetailsById);
    router.get("/api/config/endpoint/all").handler(this::getEndpointStatus);
    router.get("/api/config/endpoint/:label").handler(this::getEndpointStatusById);
    router.get("/*").handler(StaticHandler.create());

    router.post("/api/config/endpoint/:label/:state").handler(this::setEndpointStatusById);

    HttpServer server = vertx.createHttpServer().requestHandler(router::accept)
            .listen(config().getInteger("http.port", 8080), ar -> {
                online = ar.succeeded();
            });
}
 
开发者ID:benemon,项目名称:he-rss-poll,代码行数:38,代码来源:UIServiceVerticle.java

示例9: queryResult

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public static BodyCodecImpl<GraphQLQueryResult> queryResult() {
	return new BodyCodecImpl<>(buff -> {
		JsonObject result = new JsonObject(buff.toString());
		GraphQLQueryResult decoded = new GraphQLQueryResult(result.getJsonObject("data"), result.getJsonArray("errors"));  
		return decoded;
	});
}
 
开发者ID:tibor-kocsis,项目名称:vertx-graphql-utils,代码行数:8,代码来源:GraphQLBodyCodec.java

示例10: getArray

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
default JsonArray getArray(String key) {
    JsonObject obj = get(key);

    if (obj == null) {
        return null;
    }

    if (!obj.containsKey("array")) {
        throw new IllegalStateException("cached object isnt an array.");
    }

    return obj.getJsonArray("array");
}
 
开发者ID:open-erp-systems,项目名称:erp-frontend,代码行数:14,代码来源:ICache.java

示例11: configureSockJsHandler

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private SockJSHandler configureSockJsHandler(VertxContext vertxContext, BridgeOptions bridgeOptions,
                                             JsonObject config) {
    SockJSHandler sockJSHandler = SockJSHandler.create(vertxContext.vertx());
    sockJSHandler.bridge(bridgeOptions, event -> event.complete(true));
    JsonArray jsonArray=config.getJsonArray(ALLOWED_ORIGINS, new JsonArray().add("*"));

    sockJSHandler.socketHandler(event -> jsonArray.forEach(o -> event.headers().set(ACCESS_CONTROL_ALLOW_ORIGIN, (String)o)));
    return sockJSHandler;
}
 
开发者ID:GwtDomino,项目名称:domino-event-bus,代码行数:10,代码来源:VertxConfigSockJsConfigurator.java

示例12: CouchbaseConfig

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public CouchbaseConfig(JsonObject datasourceConfig) {
  this.nodes = new ArrayList<>();
  JsonArray jsonArray = datasourceConfig.getJsonArray("nodes", new JsonArray().add("localhost"));
  jsonArray.forEach(o -> nodes.add((String) o));
}
 
开发者ID:tsegismont,项目名称:vertx-musicstore,代码行数:6,代码来源:CouchbaseConfig.java

示例13: canPageLoans

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Test
public void canPageLoans()
  throws InterruptedException,
  MalformedURLException,
  TimeoutException,
  ExecutionException,
  UnsupportedEncodingException {

  createLoan(loanRequest());
  createLoan(loanRequest());
  createLoan(loanRequest());
  createLoan(loanRequest());
  createLoan(loanRequest());
  createLoan(loanRequest());
  createLoan(loanRequest());

  CompletableFuture<JsonResponse> firstPageCompleted = new CompletableFuture();
  CompletableFuture<JsonResponse> secondPageCompleted = new CompletableFuture();

  client.get(loanStorageUrl() + "?limit=4", StorageTestSuite.TENANT_ID,
    ResponseHandler.json(firstPageCompleted));

  client.get(loanStorageUrl() + "?limit=4&offset=4", StorageTestSuite.TENANT_ID,
    ResponseHandler.json(secondPageCompleted));

  JsonResponse firstPageResponse = firstPageCompleted.get(5, TimeUnit.SECONDS);
  JsonResponse secondPageResponse = secondPageCompleted.get(5, TimeUnit.SECONDS);

  assertThat(String.format("Failed to get first page of loans: %s",
    firstPageResponse.getBody()),
    firstPageResponse.getStatusCode(), is(200));

  assertThat(String.format("Failed to get second page of loans: %s",
    secondPageResponse.getBody()),
    secondPageResponse.getStatusCode(), is(200));

  JsonObject firstPage = firstPageResponse.getJson();
  JsonObject secondPage = secondPageResponse.getJson();

  JsonArray firstPageLoans = firstPage.getJsonArray("loans");
  JsonArray secondPageLoans = secondPage.getJsonArray("loans");

  assertThat(firstPageLoans.size(), is(4));
  assertThat(firstPage.getInteger("totalRecords"), is(7));

  assertThat(secondPageLoans.size(), is(3));
  assertThat(secondPage.getInteger("totalRecords"), is(7));
}
 
开发者ID:folio-org,项目名称:mod-circulation-storage,代码行数:49,代码来源:LoansApiTest.java

示例14: canSearchByUserId

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Test
public void canSearchByUserId()
  throws MalformedURLException,
  InterruptedException,
  ExecutionException,
  TimeoutException,
  UnsupportedEncodingException {

  UUID firstUserId = UUID.randomUUID();
  UUID secondUserId = UUID.randomUUID();

  String queryTemplate = loanStorageUrl() + "?query=userId=\"%s\"";

  createLoan(new LoanRequestBuilder().withUserId(firstUserId).create());
  createLoan(new LoanRequestBuilder().withUserId(firstUserId).create());
  createLoan(new LoanRequestBuilder().withUserId(firstUserId).create());
  createLoan(new LoanRequestBuilder().withUserId(firstUserId).create());

  createLoan(new LoanRequestBuilder().withUserId(secondUserId).create());
  createLoan(new LoanRequestBuilder().withUserId(secondUserId).create());
  createLoan(new LoanRequestBuilder().withUserId(secondUserId).create());

  CompletableFuture<JsonResponse> firstUserSearchCompleted = new CompletableFuture();
  CompletableFuture<JsonResponse> secondUserSeatchCompleted = new CompletableFuture();

  client.get(String.format(queryTemplate, firstUserId), StorageTestSuite.TENANT_ID,
    ResponseHandler.json(firstUserSearchCompleted));

  client.get(String.format(queryTemplate, secondUserId), StorageTestSuite.TENANT_ID,
    ResponseHandler.json(secondUserSeatchCompleted));

  JsonResponse firstPageResponse = firstUserSearchCompleted.get(5, TimeUnit.SECONDS);
  JsonResponse secondPageResponse = secondUserSeatchCompleted.get(5, TimeUnit.SECONDS);

  assertThat(String.format("Failed to get loans for first user: %s",
    firstPageResponse.getBody()),
    firstPageResponse.getStatusCode(), is(200));

  assertThat(String.format("Failed to get loans for second user: %s",
    secondPageResponse.getBody()),
    secondPageResponse.getStatusCode(), is(200));

  JsonObject firstPage = firstPageResponse.getJson();
  JsonObject secondPage = secondPageResponse.getJson();

  JsonArray firstPageLoans = firstPage.getJsonArray("loans");
  JsonArray secondPageLoans = secondPage.getJsonArray("loans");

  assertThat(firstPageLoans.size(), is(4));
  assertThat(firstPage.getInteger("totalRecords"), is(4));

  assertThat(secondPageLoans.size(), is(3));
  assertThat(secondPage.getInteger("totalRecords"), is(3));
}
 
开发者ID:folio-org,项目名称:mod-circulation-storage,代码行数:55,代码来源:LoansApiTest.java

示例15: canFilterByLoanStatus

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Test
public void canFilterByLoanStatus()
  throws MalformedURLException,
  InterruptedException,
  ExecutionException,
  TimeoutException,
  UnsupportedEncodingException {

  UUID userId = UUID.randomUUID();

  String queryTemplate = "query=userId=\"%s\"+and+status.name=\"%s\"";

  createLoan(loanRequest(userId, "Open"));
  createLoan(loanRequest(userId, "Open"));
  createLoan(loanRequest(userId, "Closed"));
  createLoan(loanRequest(userId, "Closed"));
  createLoan(loanRequest(userId, "Closed"));
  createLoan(loanRequest(userId, "Closed"));

  CompletableFuture<JsonResponse> openSearchComppleted = new CompletableFuture();
  CompletableFuture<JsonResponse> closedSearchCompleted = new CompletableFuture();

  client.get(loanStorageUrl(), String.format(queryTemplate, userId, "Open"),
    StorageTestSuite.TENANT_ID, ResponseHandler.json(openSearchComppleted));

  client.get(loanStorageUrl(), String.format(queryTemplate, userId, "Closed"),
    StorageTestSuite.TENANT_ID, ResponseHandler.json(closedSearchCompleted));

  JsonResponse openLoansResponse = openSearchComppleted.get(5, TimeUnit.SECONDS);
  JsonResponse closedLoansResponse = closedSearchCompleted.get(5, TimeUnit.SECONDS);

  assertThat(String.format("Failed to get open loans: %s",
    openLoansResponse.getBody()),
    openLoansResponse.getStatusCode(), is(200));

  assertThat(String.format("Failed to get closed loans: %s",
    closedLoansResponse.getBody()),
    closedLoansResponse.getStatusCode(), is(200));

  JsonObject openLoans = openLoansResponse.getJson();
  JsonObject closedLoans = closedLoansResponse.getJson();

  JsonArray firstPageLoans = openLoans.getJsonArray("loans");
  JsonArray secondPageLoans = closedLoans.getJsonArray("loans");

  assertThat(firstPageLoans.size(), is(2));
  assertThat(openLoans.getInteger("totalRecords"), is(2));

  assertThat(secondPageLoans.size(), is(4));
  assertThat(closedLoans.getInteger("totalRecords"), is(4));
}
 
开发者ID:folio-org,项目名称:mod-circulation-storage,代码行数:52,代码来源:LoansApiTest.java


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