當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。