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


Java JSONObject.optJSONObject方法代码示例

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


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

示例1: load

import org.json.JSONObject; //导入方法依赖的package包/类
private void load() {
	StatsManager.increment(DatabaseEnum.USER_LOADED);

	JSONObject guildObj = Database.opt(guild.getStringID());
	if(guildObj == null) {
		return;
	}

	JSONObject usersObj = guildObj.optJSONObject(DBGuild.USERS_KEY);
	if(usersObj == null) {
		return;
	}

	JSONObject userObj = usersObj.optJSONObject(Long.toString(userID));
	if(userObj == null) {
		return;
	}

	this.coins = userObj.optInt(COINS_KEY);
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:21,代码来源:DBUser.java

示例2: isFrameOrIFrame

import org.json.JSONObject; //导入方法依赖的package包/类
private static boolean isFrameOrIFrame(JSONObject message) {
  String method = message.optString("method");
  JSONObject params = message.optJSONObject("params");

  if (NODE_INSERTED.equals(method)
      && params != null
      && "IFRAME".equals(params.optJSONObject("node").optString("nodeName"))) {
    return true;
  }
  if (NODE_INSERTED.equals(method)
      && params != null
      && "FRAME".equals(params.optJSONObject("node").optString("nodeName"))) {
    return true;
  }
  return false;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:17,代码来源:EventFactory.java

示例3: decode

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
void decode(JSONObject object) throws ProcBridgeException {
    try {
        String api = object.getString(Protocol.KEY_API);
        if (api.isEmpty()) {
            throw ProcBridgeException.malformedInputData();
        }
        this.api = api;

        JSONObject body = object.optJSONObject(Protocol.KEY_BODY);
        if (body != null) {
            this.body = body;
        }

    } catch (JSONException ex) {
        throw ProcBridgeException.malformedInputData();
    }
}
 
开发者ID:gongzhang,项目名称:proc-bridge,代码行数:19,代码来源:Protocol.java

示例4: BehaviorOutput

import org.json.JSONObject; //导入方法依赖的package包/类
public BehaviorOutput(JSONObject json) {
    mGuid = json.optString(Keys.Guid);
    mBehavior = json.optString(Keys.Behavior);

    JSONObject params = json.optJSONObject(Keys.Parameters);
    if (params != null && params.length() > 0) {
        mParameters = ParameterValue.getParameterValueDict(params);
    }
}
 
开发者ID:pullstring,项目名称:pullstring-android,代码行数:10,代码来源:BehaviorOutput.java

示例5: load

import org.json.JSONObject; //导入方法依赖的package包/类
private void load() {
	StatsManager.increment(DatabaseEnum.GUILD_LOADED);

	JSONObject guildObj = Database.opt(guild.getStringID());
	if(guildObj == null) {
		return;
	}

	JSONObject settingsObj = guildObj.optJSONObject(SETTINGS_KEY);
	if(settingsObj != null) {
		for(String settingKey : settingsObj.keySet()) {
			settingsMap.put(SettingEnum.valueOf(settingKey.toUpperCase()), settingsObj.get(settingKey));
		}
	}
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:16,代码来源:DBGuild.java

示例6: NotifyOptions

import org.json.JSONObject; //导入方法依赖的package包/类
public NotifyOptions(String subscriberType, JSONObject json) throws JSONException {
  String idsStr = json.optString(Subscriber.IDS);
  subscriber = new Subscriber(subscriberType, StringUtil.getList(idsStr));
  frequency = json.getInt(FREQUENCY);
  method = json.getString(METHOD);
  smsNotify = json.optBoolean(SMS_NOTIFY);
  JSONObject repeatOptionsJson = json.optJSONObject(REPEAT_OPTIONS);
  if (repeatOptionsJson != null) {
    repeatOptions = new RepeatOptions(repeatOptionsJson);
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:12,代码来源:EventSpec.java

示例7: Json2Entity

import org.json.JSONObject; //导入方法依赖的package包/类
public BaseBean Json2Entity(String content) {
    this.cashierInfo = new CashierInfo();
    EALogger.i(IDataSource.SCHEME_HTTP_TAG, "收银台接口数据:" + content);
    try {
        JSONObject jo = new JSONObject(content);
        this.cashierInfo.setStatus(jo.optString("status"));
        this.cashierInfo.setMessage(jo.optString("message"));
        JSONObject result = jo.optJSONObject("result");
        if (result == null) {
            return this.cashierInfo;
        }
        JSONObject object = result.optJSONObject("payMentResult");
        if (object != null) {
            this.cashierInfo.setVersion(object.optString("version"));
            this.cashierInfo.setService(object.optString(NotificationCompat.CATEGORY_SERVICE));
            this.cashierInfo.setMerchant_business_id(object.optString("merchantBusinessId"));
            this.cashierInfo.setUser_id(object.optString(UserInfoDb.USER_ID));
            this.cashierInfo.setNotify_url(object.optString("notifyUrl"));
            this.cashierInfo.setMerchant_no(object.optString("merchantNo"));
            this.cashierInfo.setOut_trade_no(object.optString("outTradeNo"));
            this.cashierInfo.setPrice(object.optString("price"));
            this.cashierInfo.setCurrency(object.optString("currency"));
            this.cashierInfo.setPay_expire(object.optString("payExpire"));
            this.cashierInfo.setProduct_id(object.optString("productId"));
            this.cashierInfo.setProduct_name(object.optString("productName"));
            this.cashierInfo.setProduct_desc(object.optString("productDesc"));
            this.cashierInfo.setTimestamp(object.optString("timestamp"));
            this.cashierInfo.setKey_index(object.optString("keyIndex"));
            this.cashierInfo.setInput_charset(object.optString("inputCharset"));
            this.cashierInfo.setIp(object.optString("ip"));
            this.cashierInfo.setSign_type(object.optString("signType"));
            this.cashierInfo.setSign(object.optString(TradeInfo.SIGN));
            this.cashierInfo.setHb_fq(object.optString("hbFq"));
        }
        return this.cashierInfo;
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:40,代码来源:ParserCashier.java

示例8: login

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
public void login(String token, ShardInfo shardInfo, SessionReconnectQueue reconnectQueue) throws LoginException, RateLimitedException {
    setStatus(Status.LOGGING_IN);
    if(token == null || token.isEmpty()) throw new LoginException("Provided token was null or empty!");

    setToken(token);
    verifyToken();
    this.shardInfo = shardInfo;
    JDAImpl.LOG.info("Login Successful!");

    client = new ServerWebSocketClient(this, reconnectQueue, gatewayServer);

    JSONObject cachedPresence = gatewayServer.cachedPresence;
    if(cachedPresence != null) {
        JSONObject game = cachedPresence.optJSONObject("game");
        if(game != null) {
            getPresence().setPresence(
                    OnlineStatus.fromKey(cachedPresence.getString("status")),
                    Game.of(game.getString("name"), game.optString("url")),
                    cachedPresence.getBoolean("afk")
            );
        } else {
            getPresence().setPresence(
                    OnlineStatus.fromKey(cachedPresence.getString("status")),
                    null,
                    cachedPresence.getBoolean("afk")
            );
        }
        gatewayServer.cachedPresence = null;
    }

    if(shutdownHook != null) {
        Runtime.getRuntime().addShutdownHook(shutdownHook);
    }
}
 
开发者ID:natanbc,项目名称:discord-bot-gateway,代码行数:36,代码来源:ServerJDA.java

示例9: isHotPointTokenInvalid

import org.json.JSONObject; //导入方法依赖的package包/类
private boolean isHotPointTokenInvalid(JSONObject object) {
    boolean isInvalid = false;
    JSONObject body = object.optJSONObject("body");
    if (!isNull(body) && TextUtils.equals(body.optString("code"), "403")) {
        isInvalid = true;
    }
    LogInfo.log("isHotPointTokenInvalid", "isInvalid : " + isInvalid);
    return isInvalid;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:10,代码来源:LetvBaseParser.java

示例10: isPlayRecordTokenInvalid

import org.json.JSONObject; //导入方法依赖的package包/类
private boolean isPlayRecordTokenInvalid(JSONObject object) {
    boolean isInvalid = false;
    JSONObject header = object.optJSONObject("header");
    if (!isNull(header) && TextUtils.equals(header.optString("status"), "5")) {
        isInvalid = true;
    }
    LogInfo.log("playRecordTokenInvalid", "isInvalid : " + isInvalid);
    return isInvalid;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:10,代码来源:LetvBaseParser.java

示例11: setCallback

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * Sets the callback which will be called when the request finishes.
 *
 * @param callback the callback
 */
public final void setCallback(final Callback callback) {
    // Wrap callback to parse debug response if Graph Debug Mode is Enabled.
    if (FacebookSdk.isLoggingBehaviorEnabled(LoggingBehavior.GRAPH_API_DEBUG_INFO)
            || FacebookSdk.isLoggingBehaviorEnabled(LoggingBehavior.GRAPH_API_DEBUG_WARNING)) {
        Callback wrapper = new Callback() {
            @Override
            public void onCompleted(GraphResponse response) {
                JSONObject responseObject = response.getJSONObject();
                JSONObject debug =
                        responseObject != null ? responseObject.optJSONObject(DEBUG_KEY) : null;
                JSONArray debugMessages =
                        debug != null ? debug.optJSONArray(DEBUG_MESSAGES_KEY) : null;
                if (debugMessages != null) {
                    for (int i = 0; i < debugMessages.length(); ++i) {
                        JSONObject debugMessageObject = debugMessages.optJSONObject(i);
                        String debugMessage = debugMessageObject != null
                                ? debugMessageObject.optString(DEBUG_MESSAGE_KEY)
                                : null;
                        String debugMessageType = debugMessageObject != null
                                ? debugMessageObject.optString(DEBUG_MESSAGE_TYPE_KEY)
                                : null;
                        String debugMessageLink = debugMessageObject != null
                                ? debugMessageObject.optString(DEBUG_MESSAGE_LINK_KEY)
                                : null;
                        if (debugMessage != null && debugMessageType != null) {
                            LoggingBehavior behavior = LoggingBehavior.GRAPH_API_DEBUG_INFO;
                            if (debugMessageType.equals("warning")) {
                                behavior = LoggingBehavior.GRAPH_API_DEBUG_WARNING;
                            }
                            if (!Utility.isNullOrEmpty(debugMessageLink)) {
                                debugMessage += " Link: " + debugMessageLink;
                            }
                            Logger.log(behavior, TAG, debugMessage);
                        }
                    }
                }
                if (callback != null) {
                    callback.onCompleted(response);
                }
            }
        };
        this.callback = wrapper;
    } else {
        this.callback = callback;
    }

}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:53,代码来源:GraphRequest.java

示例12: onResponse

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
public void onResponse(Call call, Response response) throws IOException {
    if (response.code() != 200) {
        // Toast.makeText(SettingActivity.this, "服务器连接失败!", Toast.LENGTH_SHORT).show();
        return;
    }
    String result = response.body().string();
    LogUtil.d("result:" + result);
    try {
        JSONObject jsonObj = new JSONObject(result);
        if (jsonObj != null) {
            String retCode = jsonObj.optString("retCode");
            if (retCode != null && retCode.equals("0")) {
                // 在此处理业务逻辑
                JSONObject bizDataJsonObj = jsonObj.optJSONObject("bizData");
                if (bizDataJsonObj != null) {
                    final String retVersionCode = bizDataJsonObj.optString("retVersionCode");
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            swipRefreshLayout.setRefreshing(false);

                            if ("0".equals(retVersionCode)) {
                                //不需要更新
                                SimpleDialog.show(SettingActivity.this, "已是最新版本,无需更新!");
                            } else if ("1".equals(retVersionCode)) {

                                SimpleDialog.forceShow(SettingActivity.this, "检查到新版本,是否立刻升级?", null, new SimpleDialog.OnPositiveClickListener() {
                                    @Override
                                    public void onPositiveClick() {
                                        getAppDownloadUrl();
                                    }
                                });

                            }
                        }
                    });
                }
                return;
            }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:46,代码来源:SettingActivity.java

示例13: parseWith

import org.json.JSONObject; //导入方法依赖的package包/类
public void parseWith(@NonNull JSONObject data, @NonNull final MVHelper resolver, boolean isParseCell) {
    if (TangramBuilder.isPrintLog()) {
        if (serviceManager == null) {
            throw new RuntimeException("serviceManager is null when parsing card");
        }
    }

    this.extras = data;
    this.type = data.optInt(KEY_TYPE, type);
    this.stringType = data.optString(KEY_TYPE);
    id = data.optString(KEY_ID, id == null ? "" : id);

    loadMore = data.optInt(KEY_LOAD_TYPE, 0) == LOAD_TYPE_LOADMORE;
    //you should alway assign hasMore to indicate there's more data explicitly
    if (data.has(KEY_HAS_MORE)) {
        hasMore = data.optBoolean(KEY_HAS_MORE);
    } else {
        if (data.has(KEY_LOAD_TYPE)) {
            hasMore = data.optInt(KEY_LOAD_TYPE) == LOAD_TYPE_LOADMORE;
        }
    }
    load = data.optString(KEY_API_LOAD, null);
    loadParams = data.optJSONObject(KEY_API_LOAD_PARAMS);
    loaded = data.optBoolean(KEY_LOADED, false);

    maxChildren = data.optInt(KEY_MAX_CHILDREN, maxChildren);
    // parsing header
    if (Utils.isSupportHeaderFooter(stringType) && isParseCell) {
        JSONObject header = data.optJSONObject(KEY_HEADER);
        parseHeaderCell(resolver, header);
    }

    // parsing body
    JSONArray componentArray = data.optJSONArray(KEY_ITEMS);
    if (componentArray != null && isParseCell) {
        final int cellLength = Math.min(componentArray.length(), maxChildren);
        for (int i = 0; i < cellLength; i++) {
            final JSONObject cellData = componentArray.optJSONObject(i);
            createCell(resolver, cellData, true);
        }
    }
    // parsing footer
    if (Utils.isSupportHeaderFooter(stringType) && isParseCell) {
        JSONObject footer = data.optJSONObject(KEY_FOOTER);
        parseFooterCell(resolver, footer);
    }

    JSONObject styleJson = data.optJSONObject(KEY_STYLE);

    parseStyle(styleJson);

}
 
开发者ID:alibaba,项目名称:Tangram-Android,代码行数:53,代码来源:Card.java

示例14: handleData

import org.json.JSONObject; //导入方法依赖的package包/类
private void handleData(JSONObject object) {
    if (object != null) {
        this.mIntroduceURL = object.optString("link_url");
        this.mCourseID = object.optInt("sports_course_id");
        setTitle(object.optString("name"));
        JSONObject data = object.optJSONObject("sports_days");
        int total = data.optInt("total");
        int finished = data.optInt("finished");
        this.tv_course_count.setText(String.valueOf(total));
        this.tv_course_finished.setText(String.valueOf(finished));
        this.view_course_finish.setVisibility(total == finished ? 0 : 8);
        this.viewCourseProgress.setMax(total);
        this.viewCourseProgress.setProgress(finished);
        this.imageLoader.displayImage(data.optString("pic_url"), this.iv_header_bg,
                ImageLoaderOptions.randomColor());
        List<CourseInfo> courseInfos = FastJsonUtils.parseList(data.optString("sports_days"),
                CourseInfo.class);
        if (courseInfos != null && courseInfos.size() != 0) {
            this.mDataList.clear();
            this.mDataList.addAll(courseInfos);
            int todayID = data.optInt("today_id");
            int index = 1;
            List<FinishedCourseDay> finishedDayList = FastJsonUtils.parseList(data.optString
                    ("finish_days"), FinishedCourseDay.class);
            for (CourseInfo course : this.mDataList) {
                for (CourseItemInfo item : course.items) {
                    int index2 = index + 1;
                    item.index = index;
                    item.download = DownloadHelper.getInstance().hasDownload(item.video_url);
                    if (item.id == todayID) {
                        item.today = true;
                        if (this.mTabIndex == 0) {
                            this.mTabIndex = this.mDataList.indexOf(course);
                        }
                    } else {
                        item.today = false;
                    }
                    if (finishedDayList != null && finishedDayList.size() > 0) {
                        for (FinishedCourseDay day : finishedDayList) {
                            if (item.id == day.id) {
                                item.date = day.date;
                            }
                        }
                    }
                    index = index2;
                }
            }
            initView();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:52,代码来源:SportCourseActivity.java

示例15: onCreate

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Entity$$CREATOR.create("", false);
    limitJsonTv = (TextView) findViewById(R.id.limitjson_ms);
    try {
        JSONObject root = new JSONObject("");
        root.opt("");
        root.optInt("");
        root.optBoolean("");
        root.optLong("");
        float aa = (float) root.optDouble("");
        root.optString("");

        root.optJSONObject("");
        root.optJSONArray("");
        int[] a;
        if (root.has("arr")) {
            JSONArray array = root.optJSONArray("");
            int size = array.length();
            a = new int[size];
            for (int i = 0; i < size; i++) {
                a[i] = array.optInt(i);
            }
        }


    } catch (JSONException e) {
        e.printStackTrace();
    }

    testLimitJson();

    LinearGraphView tu = (LinearGraphView) findViewById(R.id.line_graphic);

    ArrayList<Double> yList = new ArrayList<Double>();
    yList.add((double) 2.103);
    yList.add(4.05);
    yList.add(6.60);
    yList.add(3.08);
    yList.add(4.32);
    yList.add(2.0);
    yList.add(1115.0);

    ArrayList<String> xRawDatas = new ArrayList<String>();
    xRawDatas.add("05-19");
    xRawDatas.add("05-20");
    xRawDatas.add("05-21");
    xRawDatas.add("05-22");
    xRawDatas.add("05-23");
    xRawDatas.add("05-24");
    xRawDatas.add("05-25");
    xRawDatas.add("05-26");
    tu.setData(yList, xRawDatas, 8, 2);
}
 
开发者ID:freelifer,项目名称:limitjson,代码行数:57,代码来源:MainActivity.java


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