com.alibaba.fastjson.JSONObject.getString()

Here are the examples of the java api com.alibaba.fastjson.JSONObject.getString() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3343 Examples 7

19 Source : SignHandler.java
with MIT License
from zion223

// 注册Handler
public static void onSignUp(String response, ISignListener signListener) {
    final JSONObject profileJson = JSON.parseObject(response).getJSONObject("data");
    final String username = profileJson.getString("username");
    // 数据库插入操作
    AccountManager.setSignState(true);
    // 注册成功
    if (signListener != null) {
        signListener.onSignUpSuccess();
    }
}

19 Source : HunterConfigTemplate.java
with MIT License
from zhangyd-c

public static String getConfig(String platform) {
    if (configTemplate.containsKey(platform)) {
        return configTemplate.getString(platform);
    }
    throw new HunterException("暂不支持该平台[" + platform + "]");
}

19 Source : OrderNumberRule.java
with Apache License 2.0
from zhangdaiscott

@Override
public Object execute(JSONObject params, JSONObject formData) {
    String prefix = "CN";
    // 订单前缀默认为CN 如果规则参数不为空,则取自定义前缀
    if (params != null) {
        Object obj = params.get("prefix");
        if (obj != null)
            prefix = obj.toString();
    }
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
    int random = RandomUtils.nextInt(90) + 10;
    String value = prefix + format.format(new Date()) + random;
    // 根据formData的值的不同,生成不同的订单号
    String name = formData.getString("name");
    if (!StringUtils.isEmpty(name)) {
        value += name;
    }
    return value;
}

19 Source : FastjsonAdapter.java
with MIT License
from zgqq

@Override
public String getString(String key) {
    return jsonObject.getString(key);
}

19 Source : ListUtils.java
with Apache License 2.0
from yl-yue

/**
 * {@linkplain List}-{@linkplain JSONObject} 转 {@linkplain List}-{@linkplain String}
 *
 * @param list 		需要转换的List
 * @param keepKey	保留值的key
 * @return			转换后的List
 */
public static List<String> toList(List<JSONObject> list, String keepKey) {
    List<String> toList = new ArrayList<>();
    for (JSONObject json : list) {
        String value = json.getString(keepKey);
        toList.add(value);
    }
    return toList;
}

19 Source : ListUtils.java
with Apache License 2.0
from yl-yue

/**
 * {@linkplain List} - {@linkplain JSONObject} 转 {@linkplain List} - {@linkplain String} 并去除重复元素
 *
 * @param list 		需要转换的List
 * @param keepKey	保留值的key
 * @return			处理后的List
 */
public static List<String> toListAndDistinct(List<JSONObject> list, String keepKey) {
    List<String> toList = new ArrayList<>();
    for (JSONObject json : list) {
        String value = json.getString(keepKey);
        toList.add(value);
    }
    return distinct(toList);
}

19 Source : LianlianPayUtil.java
with Apache License 2.0
from yi-jun

/**
 * RSA签名验证
 *
 * @param reqObj
 * @return
 * @author guoyx
 */
private static boolean checkSignRSA(JSONObject reqObj, String rsa_public) {
    if (reqObj == null) {
        return false;
    }
    String sign = reqObj.getString("sign");
    // 生成待签名串
    String sign_src = genSignData(reqObj);
    try {
        if (LianlianTraderRSAUtil.checksign(rsa_public, sign_src, sign)) {
            return true;
        } else {
            return false;
        }
    } catch (Exception e) {
        return false;
    }
}

19 Source : LianlianPayUtil.java
with Apache License 2.0
from yi-jun

/**
 * 加签
 *
 * @param reqObj
 * @param rsa_private
 * @param md5_key
 * @return
 * @author guoyx
 */
public static String addSign(JSONObject reqObj, String rsa_private, String md5_key) {
    if (reqObj == null) {
        return "";
    }
    String sign_type = reqObj.getString("sign_type");
    if (LianlianSignTypeEnum.MD5.getCode().equals(sign_type)) {
        return addSignMD5(reqObj, md5_key);
    } else {
        return addSignRSA(reqObj, rsa_private);
    }
}

19 Source : LianlianPayUtil.java
with Apache License 2.0
from yi-jun

/**
 * 签名验证
 *
 * @param reqStr
 * @return
 */
public static boolean checkSign(String reqStr, String rsa_public, String md5_key) {
    JSONObject reqObj = JSON.parseObject(reqStr);
    if (reqObj == null) {
        return false;
    }
    String sign_type = reqObj.getString("sign_type");
    if (LianlianSignTypeEnum.MD5.getCode().equals(sign_type)) {
        return checkSignMD5(reqObj, md5_key);
    } else {
        return checkSignRSA(reqObj, rsa_public);
    }
}

19 Source : LianlianPayUtil.java
with Apache License 2.0
from yi-jun

/**
 * MD5签名验证
 *
 * @param signSrc
 * @param sign
 * @return
 * @author guoyx
 */
private static boolean checkSignMD5(JSONObject reqObj, String md5_key) {
    if (reqObj == null) {
        return false;
    }
    String sign = reqObj.getString("sign");
    // 生成待签名串
    String sign_src = genSignData(reqObj);
    sign_src += "&key=" + md5_key;
    try {
        if (sign.equals(LianlianMd5Algorithm.getInstance().md5Digest(sign_src.getBytes("utf-8")))) {
            return true;
        } else {
            return false;
        }
    } catch (UnsupportedEncodingException e) {
        return false;
    }
}

19 Source : WXUtils.java
with BSD 3-Clause "New" or "Revised" License
from YClimb

/**
 * 网页授权获取用户信息时用于获取access_token以及openid
 * 请求路径:https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code(最后一个参数不变)
 * @param code c
 * @return access_token json obj
 *
 * @author yclimb
 * @date 2018/7/30
 */
public JSONObject getJsapiAccessTokenByCode(String code) {
    if (StringUtils.isBlank(code)) {
        return null;
    }
    try {
        // 获取access_token
        String access_token_json = restTemplate.getForObject(WXURL.OAUTH_ACCESS_TOKEN_URL, String.clreplaced, WXPayConstants.APP_ID_XXX, WXPayConstants.SECRET_XXX, code);
        log.info("getAccessToken:access_token_json:{}", access_token_json);
        if (StringUtils.isBlank(access_token_json)) {
            return null;
        }
        JSONObject jsonObject = JSON.parseObject(access_token_json);
        if (StringUtils.isBlank(jsonObject.getString("access_token"))) {
            return null;
        }
        return jsonObject;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    return null;
}

19 Source : NginxAccess.java
with MIT License
from yangziwen

public static NginxAccess fromJsonObject(JSONObject accessObj) {
    if (accessObj == null) {
        return null;
    }
    try {
        String url = accessObj.getString("url");
        return NginxAccess.builder().url(url).method(accessObj.getString("method")).code(NumberUtils.toInt(accessObj.getString("response_code"))).upstream(accessObj.getString("upstream")).timestamp(parseTimestampToDate(accessObj.getString("timestamp")).getTime()).responseTime(new Double(NumberUtils.toDouble(accessObj.getString("response_time")) * 1000).intValue()).referrer(accessObj.getString("referrer")).backendUrl(extractBackendUrl(url)).build();
    } catch (Exception e) {
        return null;
    }
}

19 Source : ProductListFragment.java
with Apache License 2.0
from xinpengfei520

@Override
protected void initData(String content) {
    // content即为响应成功情况下,返回的product.json数据
    if (!TextUtils.isEmpty(content)) {
        LogUtils.json(TAG, content);
        // 解析json数据
        JSONObject jsonObject = JSON.parseObject(content);
        boolean isSuccess = jsonObject.getBoolean("success");
        if (isSuccess) {
            String data = jsonObject.getString("data");
            // 解析得到集合数据
            products = JSON.parseArray(data, Product.clreplaced);
            setAdapter();
        }
    } else {
        LogUtils.e(TAG, "content is null!");
    }
}

19 Source : JsonTest.java
with GNU General Public License v3.0
from xbb2yy

@Test
public void test1() {
    JSONObject object = JSON.parseObject(str1);
    String code = object.getString("code");
    System.out.println(code);
}

19 Source : JsonTest.java
with GNU General Public License v3.0
from xbb2yy

public static void main(String[] args) {
    JSONObject object = JSON.parseObject(str);
    String code = object.getString("code");
    System.out.println(code);
}

19 Source : RDBAnalyzeResultService.java
with Apache License 2.0
from xaecbd

/**
 * @param prefixKey 固定前缀
 * @param resultObjecList result
 * @param columnName 获取的列
 * @param top top
 * @return
 */
public List<String> getcolumnKeyList(String prefixKey, List<JSONObject> resultObjecList, String columnName, int top) {
    List<String> prefixKeyList = new ArrayList<>(10);
    if (null == prefixKey) {
        if (top == -1) {
            top = resultObjecList.size();
        }
        int i = 0;
        for (JSONObject tempObj : resultObjecList) {
            if (i >= top) {
                break;
            }
            prefixKeyList.add(tempObj.getString(columnName));
            i++;
        }
    } else {
        prefixKeyList.add(prefixKey);
    }
    return prefixKeyList;
}

19 Source : AlertaService.java
with Apache License 2.0
from xaecbd

/**
 * 获取virtual-email-groups对应关系
 * @return
 */
public Map<String, String> getAlarmGroupMap() {
    Map<String, String> map = new HashMap<>();
    try {
        String response = restTemplate.getForObject(alertaConfig.getAlarmGroupApi(), String.clreplaced);
        JSONArray array = JSONArray.parseArray(response);
        array.forEach(obj -> {
            JSONObject jsonObject = (JSONObject) obj;
            String name = jsonObject.getString("Name");
            jsonObject.remove("Id");
            jsonObject.remove("UniqId");
            map.put(name.toLowerCase(), jsonObject.toJSONString());
        });
    } catch (Exception e) {
        LOG.error("get virtual-email-groups has error.", e);
    }
    return map;
}

19 Source : NxcloudSMSSender.java
with MIT License
from wolforest

private int parseResponse(Response response) {
    try {
        String responseBody = Objects.requireNonNull(response.body()).string();
        log.info("nxcloud send to mobile({}) responseBody: {}", mobile, responseBody);
        JSONObject responseJson = JSON.parseObject(responseBody);
        if ("0".equalsIgnoreCase(responseJson.getString("code"))) {
            return 1;
        } else {
            return 0;
        }
    } catch (Exception e) {
        log.warn("NxcloudSMSSender send sms fail", e);
        return 0;
    }
}

19 Source : DokypaySubscriber.java
with MIT License
from wolforest

private boolean isResponseSuccess(JSONObject json) {
    if (null == json) {
        return false;
    }
    if (null == response.getString("merTransNo")) {
        return false;
    }
    paymentNo = response.getString("merTransNo");
    String status = json.getString("transStatus");
    return null != status;
}

19 Source : DokypayCreator.java
with MIT License
from wolforest

private void setPaymentAttachment(@NonNull JSONObject data) {
    payment.setOutTradeNo(data.getString("tradeNo"));
}

19 Source : DokypayCreator.java
with MIT License
from wolforest

private void setResponseAttachment(@NonNull JSONObject data) {
    attachment.set("payUrl", data.getString("url"));
}

19 Source : DLocalSubscriber.java
with MIT License
from wolforest

private boolean isResponseSuccess(JSONObject json) {
    if (null == json) {
        return false;
    }
    if (json.getString("order_id") == null) {
        return false;
    }
    paymentNo = json.getString("order_id");
    String status = json.getString("status");
    return null != status;
}

19 Source : DLocalCreator.java
with MIT License
from wolforest

private void setResponseAttachment(@NonNull JSONObject data) {
    attachment.put("payUrl", data.getString("redirect_url"));
    attachment.put("paymentNo", payment.getPaymentNo());
    attachment.put("amount", getAmount());
    attachment.put("currencyCode", "INR");
}

19 Source : DLocalCreator.java
with MIT License
from wolforest

private void updateOutTradeNo(@NonNull JSONObject data) {
    payment.setOutTradeNo(data.getString("id"));
}

19 Source : CashfreeSubscriber.java
with MIT License
from wolforest

private boolean isResponseSuccess(JSONObject json) {
    if (null == json) {
        return false;
    }
    if (json.getString("orderId") == null) {
        return false;
    }
    paymentNo = json.getString("orderId");
    String status = json.getString("txStatus");
    return null != status;
}

19 Source : CashfreeRnCreator.java
with MIT License
from wolforest

private void setResponseAttachment(@NonNull JSONObject data) {
    initPayerInfo();
    attachment.put("cftoken", data.getString("cftoken"));
    attachment.put("appId", config.getAppId());
    attachment.put("orderId", payment.getPaymentNo());
    attachment.put("orderAmount", getAmount());
    attachment.put("orderCurrency", "INR");
    attachment.put("notifyUrl", config.getNotifyUrl());
}

19 Source : CashfreeCreator.java
with MIT License
from wolforest

private void setResponseAttachment(@NonNull JSONObject data) {
    attachment.put("payUrl", data.getString("paymentLink"));
    attachment.put("orderId", payment.getPaymentNo());
    attachment.put("orderAmount", getAmount());
    attachment.put("orderCurrency", "INR");
}

19 Source : UserServiceImpl.java
with MIT License
from wligang

/**
 * 修改角色名称
 */
private void dealRoleName(JSONObject paramJson, JSONObject roleInfo) {
    String roleName = paramJson.getString("roleName");
    if (!roleName.equals(roleInfo.getString("roleName"))) {
        userDao.updateRoleName(paramJson);
    }
}

19 Source : PostFragment.java
with MIT License
from WithLei

/**
 * 根据activity获取的POSTID从服务器获取[回复对象含User对象]详情
 */
@SuppressLint("CheckResult")
private void getCommentListData() {
    RetrofitService.getCommentListData(postID).subscribe(responseBody -> {
        String response = responseBody.string();
        JSONObject obj = JSON.parseObject(response);
        if (obj.getInteger("code") != 20000) {
            ToastShort("获取评论失败惹,再试试( • ̀ω•́ )✧");
            return;
        }
        initCommentListData(obj.getString("data"));
        if (adapter == null)
            initCommentList();
        else
            adapter.notifyDataSetChanged();
    }, throwable -> ToastNetWorkError());
}

19 Source : GrabParam.java
with Apache License 2.0
from virjar

public String getParam(String key) {
    return param.getString(key);
}

19 Source : PayOrderController.java
with MIT License
from uhonliu

private String create(JSONObject params) {
    _log.info("###### 开始接收商户统一下单请求 ######");
    String logPrefix = "【商户统一下单】";
    try {
        JSONObject payContext = new JSONObject();
        JSONObject payOrder = null;
        // 验证参数有效性
        Object object = validateParams(params, payContext);
        if (object instanceof String) {
            _log.info("{}参数校验不通过:{}", logPrefix, object);
            return XXPayUtil.makeRetFail(XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_FAIL, object.toString(), null, null));
        }
        if (object instanceof JSONObject) {
            payOrder = (JSONObject) object;
        }
        if (payOrder == null) {
            return XXPayUtil.makeRetFail(XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_FAIL, "支付中心下单失败", null, null));
        }
        int result = payOrderService.createPayOrder(payOrder);
        _log.info("{}创建支付订单,结果:{}", logPrefix, result);
        if (result != 1) {
            return XXPayUtil.makeRetFail(XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_FAIL, "创建支付订单失败", null, null));
        }
        String channelCode = payOrder.getString("channelCode");
        switch(channelCode) {
            case PayConstant.PAY_CHANNEL_WX_APP:
                return payOrderService.doWxPayReq(PayConstant.WxConstant.TRADE_TYPE_APP, payOrder, payContext.getString("resKey"));
            case PayConstant.PAY_CHANNEL_WX_JSAPI:
                return payOrderService.doWxPayReq(PayConstant.WxConstant.TRADE_TYPE_JSAPI, payOrder, payContext.getString("resKey"));
            case PayConstant.PAY_CHANNEL_WX_NATIVE:
                return payOrderService.doWxPayReq(PayConstant.WxConstant.TRADE_TYPE_NATIVE, payOrder, payContext.getString("resKey"));
            case PayConstant.PAY_CHANNEL_WX_MWEB:
                return payOrderService.doWxPayReq(PayConstant.WxConstant.TRADE_TYPE_MWEB, payOrder, payContext.getString("resKey"));
            case PayConstant.PAY_CHANNEL_ALIPAY_MOBILE:
            case PayConstant.PAY_CHANNEL_ALIPAY_PC:
            case PayConstant.PAY_CHANNEL_ALIPAY_WAP:
            case PayConstant.PAY_CHANNEL_ALIPAY_QR:
                return payOrderService.doAliPayReq(channelCode, payOrder, payContext.getString("resKey"));
            default:
                return XXPayUtil.makeRetFail(XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_FAIL, "不支持的支付渠道类型[channelCode=" + channelCode + "]", null, null));
        }
    } catch (Exception e) {
        _log.error(e, "");
        return XXPayUtil.makeRetFail(XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_FAIL, "支付中心系统异常", null, null));
    }
}

19 Source : AlipayProperties.java
with MIT License
from uhonliu

/**
 * 初始化支付宝配置
 *
 * @param configParam
 * @return
 */
public AlipayProperties init(String configParam) {
    replacedert.notNull(configParam, "init alipay config error");
    JSONObject paramObj = JSON.parseObject(configParam);
    this.setAppid(paramObj.getString("appid"));
    this.setPrivateKey(paramObj.getString("private_key"));
    this.setPublicKey(paramObj.getString("public_key"));
    this.setIsSandbox(paramObj.getShortValue("is_sandbox"));
    if (this.getIsSandbox().intValue() == 1) {
        this.setUrl("https://openapi.alipaydev.com/gateway.do");
    }
    return this;
}

19 Source : ExtensionImpl.java
with Apache License 2.0
from tiankong0310

// label和messageKey在持久化时作为摘要信息,因此存双份,不打@JsonIgnore
@Override
public String getLabel() {
    if (config != null) {
        return config.getString("label");
    }
    return null;
}

19 Source : ExtensionImpl.java
with Apache License 2.0
from tiankong0310

@Override
public String getMessageKey() {
    if (config != null) {
        return config.getString("messageKey");
    }
    return null;
}

19 Source : ExtensionImpl.java
with Apache License 2.0
from tiankong0310

@JsonIgnore
@Override
public String getId() {
    if (config != null) {
        return config.getString("id");
    }
    return null;
}

19 Source : seleniumBypassAutotype1_2_68.java
with MIT License
from threedr3am

public static void main(String[] args) {
    String payload = "\n" + "{\n" + "    \"name\":\"tony\",\n" + "    \"email\":\"[email protected]\",\n" + "    \"content\":{\"$ref\":\"$x.systemInformation\"},\n" + "    \"x\":{\n" + "                \"@type\":\"java.lang.Exception\",\"@type\":\"org.openqa.selenium.WebDriverException\"\n" + "          }\n" + "}";
    try {
        JSONObject jsonObject = JSON.parseObject(payload);
        System.out.println(jsonObject.getString("content"));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

19 Source : BiLiveTask.java
with Apache License 2.0
from srcrs

@Override
public void run() {
    try {
        JSONObject json = xliveSign();
        String msg;
        String key = "code";
        /* 获取json对象的状态码code */
        if (SUCCESS.equals(json.getString(key))) {
            msg = "获得" + json.getJSONObject("data").getString("text") + " ," + json.getJSONObject("data").getString("specialText") + "✔";
        } else {
            msg = json.getString("message") + "❌";
        }
        log.info("【直播签到】: {}", msg);
        /* 直播签到后等待 3-5 秒
            ** 为防止礼物未到到账,而无法送出
            */
        Thread.sleep(new Random().nextInt(2000) + 3000);
    } catch (Exception e) {
        log.error("💔直播签到错误 : ", e);
    }
}

19 Source : TopicServiceImpl.java
with Apache License 2.0
from smartloli

/**
 * Get topic logsize, topicsize from jmx data.
 */
public String getTopicSizeAndCapacity(String clusterAlias, String topic) {
    JSONObject object = new JSONObject();
    long logSize = brokerService.getTopicRealLogSize(clusterAlias, topic);
    JSONObject topicSize;
    if ("kafka".equals(SystemConfigUtils.getProperty(clusterAlias + ".kafka.eagle.offset.storage"))) {
        topicSize = kafkaMetricsService.topicSize(clusterAlias, topic);
    } else {
        topicSize = kafkaMetricsService.topicSize(clusterAlias, topic);
    }
    object.put("logsize", logSize);
    object.put("topicsize", topicSize.getString("size"));
    object.put("sizetype", topicSize.getString("type"));
    return object.toJSONString();
}

19 Source : WorkNodeServiceHandler.java
with Apache License 2.0
from smartloli

@Override
public String getResult(String jsonObject) throws TException {
    if (isJson(jsonObject)) {
        JSONObject object = JSON.parseObject(jsonObject);
        if (object.getString(KConstants.Protocol.KEY).equals(KConstants.Protocol.HEART_BEAT)) {
            this.type = KConstants.Protocol.HEART_BEAT;
        } else if (object.getString(KConstants.Protocol.KEY).equals(KConstants.Protocol.KSQL_QUERY)) {
            this.type = KConstants.Protocol.KSQL_QUERY;
            this.ksql = object.getObject(KConstants.Protocol.VALUE, KSqlStrategy.clreplaced);
        } else if (object.getString(KConstants.Protocol.KEY).equals(KConstants.Protocol.KSQL_QUERY_LOG)) {
            this.type = KConstants.Protocol.KSQL_QUERY_LOG;
            this.jobId = object.getString(KConstants.Protocol.JOB_ID);
        }
        return handler();
    }
    return "";
}

19 Source : JSONFunction.java
with Apache License 2.0
from smartloli

/**
 * Parse a JSONObject.
 */
public String JSON(String jsonObject, String key) {
    JSONObject object = com.alibaba.fastjson.JSON.parseObject(jsonObject);
    return object.getString(key);
}

19 Source : SysUserController.java
with MIT License
from smallyunet

/**
 * 用户手机号验证
 */
@PostMapping("/phoneVerification")
public Result<String> phoneVerification(@RequestBody JSONObject jsonObject) {
    Result<String> result = new Result<String>();
    String phone = jsonObject.getString("phone");
    String smscode = jsonObject.getString("smscode");
    Object code = redisUtil.get(phone);
    if (!smscode.equals(code)) {
        result.setMessage("手机验证码错误");
        result.setSuccess(false);
        return result;
    }
    redisUtil.set(phone, smscode);
    result.setResult(smscode);
    result.setSuccess(true);
    return result;
}

19 Source : JsonUtil.java
with Apache License 2.0
from shinnlove

/**
 * 将简单的kv结构json转成map结构
 * @param jsonObject
 * @param needEmpty 是否保留值为空的查询条件
 * @return
 */
public static Map<String, String> json2Map(JSONObject jsonObject, boolean needEmpty) {
    if (jsonObject == null) {
        return null;
    }
    HashMap<String, String> result = new HashMap<String, String>();
    Set<String> keys = jsonObject.keySet();
    for (String key : keys) {
        String value = jsonObject.getString(key);
        if ((value != null && !"".equals(value)) || needEmpty) {
            result.put(key, value);
        }
    }
    return result;
}

19 Source : MobilePhoneProvinceFunction.java
with Apache License 2.0
from rule-engine

@Executor
public String executor(@Param(value = "phone", required = false) String phone) {
    if (!Validator.isMobile(phone)) {
        return StringPool.EMPTY;
    }
    String requestUrl = "https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=" + phone;
    String result = this.restTemplate.getForObject(requestUrl, String.clreplaced);
    log.info("获取手机号码归属地:{}", result);
    if (result == null || result.length() == 0) {
        return StringPool.EMPTY;
    }
    // remove __GetZoneResult_ =
    String resultJson = result.substring(18, result.length() - 1);
    System.out.println(resultJson);
    JSONObject parse = JSON.parseObject(resultJson);
    System.out.println(parse);
    return parse.getString("province");
}

19 Source : IPMIUtil.java
with GNU General Public License v2.0
from rackshift

public static String exeCommandForBrand(Account account) throws Exception {
    String commandResult = IPMIUtil.exeCommand(account, "fru");
    JSONObject fruObj = IPMIUtil.transform(commandResult);
    return fruObj.getString("Product Manufacturer");
}

19 Source : RackHDService.java
with GNU General Public License v2.0
from rackshift

public String getWorkflowStatusById(Endpoint endpoint, String instanceId) {
    try {
        String ip = "http://" + endpoint.getIp() + ":9090";
        JSONObject res = JSONObject.parseObject(RackHDHttpClientUtil.get(ip + String.format(RackHDConstants.JOBS, instanceId), null));
        return res.getString("status");
    } catch (Exception e) {
        LogUtil.error("更新workflow任务状态失败!" + ExceptionUtils.getExceptionDetail(e));
    }
    return null;
}

19 Source : AuthBaiduRequest.java
with MIT License
from qzw1210

private String getAvatar(JSONObject object) {
    String protrait = object.getString("portrait");
    return StringUtils.isEmpty(protrait) ? null : String.format("http://himg.bdimg.com/sys/portrait/item/%s.jpg", protrait);
}

19 Source : HuobiWebSocketTradeApiV21.java
with Apache License 2.0
from QuantWorldOrg

@Override
public void onData(JSONObject data) {
    if (data == null) {
        return;
    }
    String action = data.getString("action");
    if (!"push".equals(action)) {
        return;
    }
    String ch = data.getString("ch");
    if (ch.contains("accounts.update")) {
        onAccount(data);
    }
    if (ch.contains("trade.clearing")) {
        onTrade(data);
    }
    if (ch.contains("orders")) {
        onOrder(data);
    }
}

19 Source : HuobiWebSocketTradeApi.java
with Apache License 2.0
from QuantWorldOrg

@Override
public void onData(JSONObject data) {
    if (data == null) {
        return;
    }
    logger.info("更新数据:{}.", data.toJSONString());
    String op = data.getString("op");
    if (!"notify".equals(op)) {
        return;
    }
    String topic = data.getString("topic");
    if (topic.contains("orders")) {
        onOrder(data);
    }
}

19 Source : HuobiRestApi.java
with Apache License 2.0
from QuantWorldOrg

private void onQueryAccount(JSONObject data) {
    if (hasError(data)) {
        return;
    }
    JSONArray array = data.getJSONArray("data");
    for (Object jsonObject : array) {
        JSONObject accountData = ((JSONObject) jsonObject);
        if ("spot".equals(accountData.getString("type"))) {
            accountId = accountData.getString("id");
            gateway.writeLog(String.format("账户代码:%s,查询成功", accountId));
        }
    }
    queryAccountBalance();
}

19 Source : HuobiRestApi.java
with Apache License 2.0
from QuantWorldOrg

public boolean hasError(JSONObject data, String function) {
    if (!"error".equals(data.getString("status"))) {
        return false;
    }
    String errorCode = data.getString("err-code");
    String errorMsg = data.getString("err-msg");
    String orderState = data.getString("order-state");
    gateway.writeLog(String.format("%s请求出错,代码:%s, 信息:%s, 订单状态:%s", function, errorCode, errorMsg, orderState));
    return true;
}

See More Examples