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


Java JsonObject.getString方法代码示例

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


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

示例1: create

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public Single<JsonObject> create(JsonObject item) {
  if (item == null) {
    return Single.error(new IllegalArgumentException("The item must not be null"));
  }
  if (item.getString("name") == null || item.getString("name").isEmpty()) {
    return Single.error(new IllegalArgumentException("The name must not be null or empty"));
  }
  if (item.getInteger("stock", 0) < 0) {
    return Single.error(new IllegalArgumentException("The stock must greater or equal to 0"));
  }
  if (item.containsKey("id")) {
    return Single.error(new IllegalArgumentException("The created item already contains an 'id'"));
  }

  return db.rxGetConnection()
    .flatMap(conn -> {
      JsonArray params = new JsonArray().add(item.getValue("name")).add(item.getValue("stock", 0));
      return conn
        .rxUpdateWithParams(INSERT, params)
        .map(ur -> item.put("id", ur.getKeys().getLong(0)))
        .doAfterTerminate(conn::close);
    });
}
 
开发者ID:cescoffier,项目名称:various-vertx-demos,代码行数:25,代码来源:JdbcProductStore.java

示例2: AuthMgr

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public AuthMgr(JsonObject conf,AppContain app){
	
	this.authenticationUrl = conf.getString("authentication");
	this.authorisationUrl = conf.getString("authorisation");
	this.mainpage = conf.getString("mainpage");
	this.successFiled = conf.getString("successfield","userid");
	this.loginpage = conf.getString("loginpage");
	
	String authapp = conf.getString("app");
			
	String sufix = conf.getString("exclude.end");		
	String noauthpath = conf.getString("exclude.start");	
	this.setNotAuthSufix(sufix);
	this.setNoAuthPaths(noauthpath);
	if(S.isNotBlank(this.loginpage))
		this.addNoAuthPath(this.loginpage);
	
	this.authApp = app.getAppInfo(authapp);		
	
	this.authenticationUrl = this.authApp.offsetUrl(this.authenticationUrl);
	this.authorisationUrl = this.authApp.offsetUrl(this.authorisationUrl);

	this.authProvider = new GateAuthProvider(this);
	
	
}
 
开发者ID:troopson,项目名称:etagate,代码行数:27,代码来源:AuthMgr.java

示例3: generate

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public void generate(Message<JsonObject> message) {
    JsonObject metadata = message.body();
    String build = metadata.getString("build", "maven");
    String language = metadata.getString("language", "java");
    //Act as a activation flags in .gitignore
    metadata.put(build, true);
    metadata.put(language, true);
    String baseDir = metadata.getString("baseDir");
    CompositeFuture.all(
        generateFile(metadata, baseDir, BUILD.get(build)),
        generateFile(metadata, baseDir, LANGUAGES.get(language)),
        generateFile(metadata, baseDir, ".gitignore"),
        generateFile(metadata, baseDir, ".editorconfig")
    ).setHandler(ar -> {
        if (ar.failed()) {
            log.error("Impossible to generate project {} : {}", metadata, ar.cause().getMessage());
            message.fail(500, ar.cause().getMessage());
        } else {
            message.reply(null);
        }
    });
}
 
开发者ID:danielpetisme,项目名称:vertx-forge,代码行数:23,代码来源:ProjectGeneratorService.java

示例4: computeResponse

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private void computeResponse(RoutingContext rc) {
    JsonObject json = rc.getBodyAsJson();
    String name = json.getString("name");
    Double price = prices.computeIfAbsent(name, k -> (double) random.nextInt(50));
    Integer q = Integer.parseInt(json.getString("quantity", "1"));
    rc.response().end(new JsonObject()
        .put("name", name)
        .put("price", price)
        .put("quantity", json.getString("quantity", "1"))
        .put("total", "" + (price * q))
        .encodePrettily());
}
 
开发者ID:cescoffier,项目名称:vertx-chtijug-2017,代码行数:13,代码来源:PricerVerticle.java

示例5: addToList

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private void addToList(RoutingContext rc) {
    JsonObject json = rc.getBodyAsJson();
    String name = json.getString("name");
    Integer quantity = json
        .getInteger("quantity", 1);

    client.hset(KEY, name, quantity.toString(), x -> {
        getList(rc);
    });
}
 
开发者ID:cescoffier,项目名称:vertx-chtijug-2017,代码行数:11,代码来源:ShoppingBackend.java

示例6: sell

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public void sell(int amount, JsonObject quote, Handler<AsyncResult<Portfolio>> resultHandler) {
    if (amount <= 0) {
        resultHandler.handle(Future.failedFuture("Cannot sell " + quote.getString("name") + " - the amount must be " +
            "greater than 0"));
        return;
    }

    double price = amount * quote.getDouble("bid");
    String name = quote.getString("name");
    int current = portfolio.getAmount(name);
    // 1) do we have enough stocks
    if (current >= amount) {
        // Yes, sell it
        int newAmount = current - amount;
        if (newAmount == 0) {
            portfolio.getShares().remove(name);
        } else {
            portfolio.getShares().put(name, newAmount);
        }
        portfolio.setCash(portfolio.getCash() + price);
        sendActionOnTheEventBus("SELL", amount, quote, newAmount);
        resultHandler.handle(Future.succeededFuture(portfolio));
    } else {
        resultHandler.handle(Future.failedFuture("Cannot sell " + amount + " of " + name + " - " + "not enough stocks " +
            "in portfolio"));
    }

}
 
开发者ID:cescoffier,项目名称:vertx-kubernetes-workshop,代码行数:30,代码来源:PortfolioServiceImpl.java

示例7: handleMsg

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public void handleMsg(Buffer data) {
    JsonObject j = data.toJsonObject();
    String msgType = j.getString(GossipMessageFactory.KEY_MSG_TYPE);
    String _data = j.getString(GossipMessageFactory.KEY_DATA);
    String cluster = j.getString(GossipMessageFactory.KEY_CLUSTER);
    String from = j.getString(GossipMessageFactory.KEY_FROM);
    if (StringUtil.isNullOrEmpty(cluster) || !GossipManager.getInstance().getCluster().equals(cluster)) {
        LOGGER.error("This message shouldn't exist my world!" + data.toString());
        return;
    }
    MessageHandler handler = null;
    MessageType type = MessageType.valueOf(msgType);
    if (type == MessageType.SYNC_MESSAGE) {
        handler = new SyncMessageHandler();
    } else if (type == MessageType.ACK_MESSAGE) {
        handler = new AckMessageHandler();
    } else if (type == MessageType.ACK2_MESSAGE) {
        handler = new Ack2MessageHandler();
    } else if (type == MessageType.SHUTDOWN) {
        handler = new ShutdownMessageHandler();
    } else {
        LOGGER.error("Not supported message type");
    }
    if (handler != null) {
        handler.handle(cluster, _data, from);
    }
}
 
开发者ID:monkeymq,项目名称:jgossip,代码行数:29,代码来源:UDPMsgService.java

示例8: getRecord

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
static Record getRecord(final JsonObject config) {
    /** Config Verify **/
    Fn.flingUp(() -> Fn.shuntZero(() -> Ruler.verify(Key.RULE_KEY, config), config),
            LOGGER);
    // Connect remote etcd to check service
    final ConcurrentMap<String, Record> registryData = ORIGIN.getRegistryData();
    final String name = config.getString(Key.NAME);
    final String address = config.getString(Key.ADDR);
    LOGGER.debug(Info.RPC_SERVICE, name, address);
    // Empty Found
    Fn.flingWeb(registryData.values().isEmpty(), LOGGER,
            _424RpcServiceException.class, RpcHelper.class,
            name, address);

    // Service status checking
    final RxHod container = new RxHod();
    // Lookup Record instance
    Observable.fromIterable(registryData.values())
            .filter(Objects::nonNull)
            .filter(item -> StringUtil.notNil(item.getName()))
            .filter(item -> name.equals(item.getName()) &&
                    address.equals(item.getMetadata().getString(Key.PATH)))
            .subscribe(container::add);
    // Service Not Found
    Fn.flingWeb(!container.successed(), LOGGER,
            _424RpcServiceException.class, RpcHelper.class,
            name, address);
    // Address Not Found
    Fn.flingWeb(!container.successed(), LOGGER,
            _424RpcServiceException.class, RpcHelper.class,
            name, address);
    final Record record = container.get();
    LOGGER.debug(Info.RPC_FOUND, record.toJson());
    return container.get();
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:36,代码来源:RpcHelper.java

示例9: FakeSourceImpl

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public FakeSourceImpl(JsonObject json) {
  super(Flowable.fromIterable(
    json.getJsonArray("items").getList()).map(Data::new)
  );
  name = json.getString("name");
}
 
开发者ID:cescoffier,项目名称:fluid,代码行数:8,代码来源:FakeSource2Factory.java

示例10: alipayRefund

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
 * 支付宝退款接口;
 *
 * @param bizContent   支付宝退款接口的业务内容请求JSON实例
 * @param acc      企业用户账户对象
 * 异步返回 是否调用成功
 *
 * @author Leibniz
 */
public void alipayRefund(RefundBizContent bizContent, JsonObject acc, String successUrl, Handler<Boolean> callback) {
    String bizContentStr = bizContent.toString(); // 将参数bizContent转成字符串

    // 检查bizContent是否合法
    if (!bizContent.checkParameters()) {
        throw new IllegalArgumentException("错误的支付宝退款接口请求业务JSON:" + bizContentStr); // 抛出异常
    }

    String notifyUrl = zfbPayNotifyUrl; // 服务器后台回调通知的url
    AliAccountInfo aliAccountInfo = new AliAccountInfo(acc.getString(ZFBAPPID), acc.getString(ZFBPRIVKEY), acc.getString(ZFBPUBKEY), successUrl, notifyUrl, null); // 该对象保存了支付宝账号的相关信息,以及请求回调地址
    AlipayClient alipayClient = AliPayCliFactory.getAlipayClient(aliAccountInfo); // 获取支付宝连接
    AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); // 创建退款请求
    request.setBizContent(bizContentStr); // 设置请求的bizContent
    AlipayTradeRefundResponse response = null;

    try {
        response = alipayClient.execute(request); // 发送退款请求并获得响应
    } catch (AlipayApiException e) { // 捕捉异常
        log.error("调用支付宝退款接口时抛出异常,请求的JSON:" + bizContentStr, e); // 打日志
    }

    // 判断是否有响应
    if (response != null) { // 响应成功
        // 判断退款是否成功
        if (response.isSuccess()) { // 退款成功
            log.info("调用成功"); // 打日志
            callback.handle(true);
            // 退款成功,其他都是错
        } else { // 退款失败
            log.error("调用支付宝退款接口错误,code={},msg={},sub_code={},sub_msg={}", response.getCode(), response.getMsg(), response.getSubCode(), response.getSubMsg()); // 打日志
            callback.handle(false);
        }
    } else { // 响应失败
        log.error("调用支付宝退款接口时发生异常,返回响应对象为null!{}", bizContentStr); // 打日志
        callback.handle(false);
    }
}
 
开发者ID:Leibnizhu,项目名称:AlipayWechatPlatform,代码行数:47,代码来源:AlipayPayService.java

示例11: create

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public <T> Single<Source<T>> create(Vertx vertx, JsonObject json) {
    String address = json.getString("address");
    if (address == null) {
        String name = json.getString("name");
        if (name != null) {
            json.put("address", name);
        } else {
            throw new IllegalArgumentException("Either address or name must be set");
        }
    }
    return Single.just(new EventBusSource<>(vertx, json));

}
 
开发者ID:cescoffier,项目名称:fluid,代码行数:15,代码来源:EventBusSourceFactory.java

示例12: CamelSink

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public CamelSink(JsonObject config) {
    endpoint = config.getString("endpoint");
    camelContext = new DefaultCamelContext();
    try {
        camelContext.start();
        producerTemplate = camelContext.createProducerTemplate();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:cescoffier,项目名称:fluid,代码行数:11,代码来源:CamelSink.java

示例13: parseSubMenus

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
protected void parseSubMenus (Menu menu, JsonArray jsonArray) {
    for (int i = 0; i < jsonArray.size(); i++) {
        //get json object
        JsonObject entry = jsonArray.getJsonObject(i);

        //get event and title
        String event = entry.getString("event");
        String title = entry.getString("title");

        //create new menu item
        MenuItem menuItem = new MenuItem(title);

        //add click handler
        menuItem.setOnAction(event1 -> {
            System.out.println("open activitiy: " + event);

            EventBus.getInstance().raiseEvent("open_activity", event);
        });

        menuItem.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN));

        //check for shortcut
        if (entry.containsKey("shortcut") && !entry.getString("shortcut").isEmpty()) {
            String keys[] = entry.getString("shortcut").split("\\+");

            if (keys.length > 1) {
                KeyCombination.Modifier modifier = null;

                if (keys[1].equals("SHIFT_DOWN")) {
                    modifier = KeyCombination.SHIFT_DOWN;
                } else {
                    throw new UnsupportedOperationException("Unsupported key code: " + keys[1]);
                }

                //KeyCombination combination = KeyCombination.keyCombination(keys[1]);

                menuItem.setAccelerator(new KeyCodeCombination(KeyCode.getKeyCode(keys[0]), modifier));
            } else if (keys.length == 1) {
                menuItem.setAccelerator(new KeyCodeCombination(KeyCode.getKeyCode(keys[0])));
            } else {
                //no shortcut is set
            }
        }

        //add menu item to menu
        menu.getItems().add(menuItem);
    }
}
 
开发者ID:open-erp-systems,项目名称:erp-frontend,代码行数:49,代码来源:DefaultMenuManager.java

示例14: getAuthenticationData

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public static String getAuthenticationData(JsonObject user) {
    return "username=" + user.getString("username") +
            "&password=" + user.getString("password") +
            "&client_name=FormClient";
}
 
开发者ID:kristenkotkas,项目名称:moviediary,代码行数:6,代码来源:Utils.java

示例15: getID

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private String getID(final Record record) {
    final JsonObject metadata = record.getMetadata();
    return metadata.getString(Origin.ID);
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:5,代码来源:ZeroApiWorker.java


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