本文整理了Java中org.json.JSONObject.optBoolean()
方法的一些代码示例,展示了JSONObject.optBoolean()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.optBoolean()
方法的具体详情如下:
包路径:org.json.JSONObject
类名称:JSONObject
方法名:optBoolean
[英]Returns the value mapped by name if it exists and is a boolean or can be coerced to a boolean. Returns false otherwise.
[中]返回按名称映射的值(如果该值存在且为布尔值或可以强制为布尔值)。否则返回false。
代码示例来源:origin: google/physical-web
/**
* Get extra boolean value.
* @param key The key of the stored value.
* @return The stored value or false if it doesn't exist in specified form.
*/
public boolean optExtraBoolean(String key) {
return mExtraData.optBoolean(key);
}
代码示例来源:origin: google/physical-web
/**
* Get extra boolean value.
* @param key The key of the stored value.
* @return The stored value or false if it doesn't exist in specified form.
*/
public boolean optExtraBoolean(String key) {
return mExtraData.optBoolean(key);
}
代码示例来源:origin: google/physical-web
/**
* Get extra boolean value.
* @param key The key of the stored value.
* @param defaultValue The value to return if the key does not exist or the value cannot be
* coerced into the necessary type.
* @return The stored value or the provided default if it doesn't exist in specified form.
*/
public boolean optExtraBoolean(String key, boolean defaultValue) {
return mExtraData.optBoolean(key, defaultValue);
}
代码示例来源:origin: google/physical-web
/**
* Get extra boolean value.
* @param key The key of the stored value.
* @param defaultValue The value to return if the key does not exist or the value cannot be
* coerced into the necessary type.
* @return The stored value or the provided default if it doesn't exist in specified form.
*/
public boolean optExtraBoolean(String key, boolean defaultValue) {
return mExtraData.optBoolean(key, defaultValue);
}
代码示例来源:origin: zzz40500/GsonFormat
/**
* Get an optional boolean associated with a key. It returns false if there
* is no such key, or if the value is not Boolean.TRUE or the String "true".
*
* @param key
* A key string.
* @return The truth.
*/
public boolean optBoolean(String key) {
return this.optBoolean(key, false);
}
代码示例来源:origin: apache/geode
/**
* Returns the value mapped by {@code name} if it exists and is a boolean or can be coerced to a
* boolean, or false otherwise.
*
* @param name The name of the field we want.
* @return The selected value if it exists.
*/
public boolean optBoolean(String name) {
return optBoolean(name, false);
}
代码示例来源:origin: robovm/robovm
/**
* Returns the value mapped by {@code name} if it exists and is a boolean or
* can be coerced to a boolean. Returns false otherwise.
*/
public boolean optBoolean(String name) {
return optBoolean(name, false);
}
代码示例来源:origin: facebook/facebook-android-sdk
public boolean getBoolean(String field) {
return jsonData.optBoolean(field);
}
代码示例来源:origin: loklak/loklak_server
/**
* Get an optional boolean associated with a key. It returns false if there
* is no such key, or if the value is not Boolean.TRUE or the String "true".
*
* @param key
* A key string.
* @return The truth.
*/
public boolean optBoolean(String key) {
return this.optBoolean(key, false);
}
代码示例来源:origin: apache/geode
public boolean getBoolean(String key) {
return jsonObject.optBoolean(key);
}
代码示例来源:origin: alibaba/Tangram-Android
public boolean optBoolParam(String key) {
if (extras.has(key)) {
return extras.optBoolean(key);
}
return style != null && style.extras != null && style.extras.optBoolean(key);
}
代码示例来源:origin: alibaba/Tangram-Android
public boolean optBoolParam(String key) {
if (extras.has(key))
return extras.optBoolean(key);
return style != null && style.extras != null && style.extras.optBoolean(key);
}
代码示例来源:origin: facebook/facebook-android-sdk
public static boolean getGateKeeperForKey(
final String name,
final String applicationId,
final boolean defaultValue) {
loadAppGateKeepersAsync();
if (applicationId == null || !fetchedAppGateKeepers.containsKey(applicationId)) {
return defaultValue;
}
return fetchedAppGateKeepers.get(applicationId).optBoolean(name, defaultValue);
}
代码示例来源:origin: facebook/facebook-android-sdk
/**
* Determines if the open graph object is for posting
* @param object The open graph object to check
* @return True if the open graph object was created for posting
*/
public static boolean isOpenGraphObjectForPost(JSONObject object) {
return object != null
? object.optBoolean(NativeProtocol.OPEN_GRAPH_CREATE_OBJECT_KEY) : false;
}
}
代码示例来源:origin: facebook/facebook-android-sdk
@Override
public void onCompleted(GraphResponse response) {
boolean success = false;
FacebookRequestError error = response.getError();
if (error == null) {
JSONObject jsonObject = response.getJSONObject();
success = jsonObject.optBoolean("success");
} else {
Log.d(TAG, "response error: " + error);
}
Log.d(
TAG,
"provideCurrentPlaceFeedback: onCompleted: response: success=" + success);
}
};
代码示例来源:origin: ankidroid/Anki-Android
public void collapseBrowser(long did) {
try {
JSONObject deck = get(did);
boolean collapsed = deck.optBoolean("browserCollapsed", false);
deck.put("browserCollapsed", !collapsed);
save(deck);
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: ankidroid/Anki-Android
/**
* Return an img link for LATEX.
*/
private static String _imgLink(String latex, JSONObject model) {
String txt = _latexFromHtml(latex);
String ext = "png";
if (model.optBoolean("latexsvg", false)) {
ext = "svg";
}
String fname = "latex-" + Utils.checksum(txt) + "." + ext;
return "<img class=latex src=\"" + fname + "\">";
}
代码示例来源:origin: facebook/facebook-android-sdk
public void testIsOpenGraphObjectForPost() {
JSONObject jsonObject = mock(JSONObject.class);
when(jsonObject.optBoolean(NativeProtocol.OPEN_GRAPH_CREATE_OBJECT_KEY)).thenReturn(true);
assertTrue(GraphUtil.isOpenGraphObjectForPost(jsonObject));
}
}
代码示例来源:origin: ankidroid/Anki-Android
private void setDeckExpander(ImageButton expander, ImageButton indent, Sched.DeckDueTreeNode node){
boolean collapsed = mCol.getDecks().get(node.did).optBoolean("collapsed", false);
// Apply the correct expand/collapse drawable
if (collapsed) {
expander.setImageDrawable(mExpandImage);
expander.setContentDescription(expander.getContext().getString(R.string.expand));
} else if (node.children.size() > 0) {
expander.setImageDrawable(mCollapseImage);
expander.setContentDescription(expander.getContext().getString(R.string.collapse));
} else {
expander.setImageDrawable(mNoExpander);
}
// Add some indenting for each nested level
int width = (int) indent.getResources().getDimension(R.dimen.keyline_1) * node.depth;
indent.setMinimumWidth(width);
}
代码示例来源:origin: ankidroid/Anki-Android
public void fillFlashcard() {
Timber.d("fillFlashcard()");
Timber.d("base url = %s", mBaseUrl);
if (mCard != null) {
CompatHelper.getCompat().setHTML5MediaAutoPlay(mCard.getSettings(), getConfigForCurrentCard().optBoolean("autoplay"));
mCard.loadDataWithBaseURL(mBaseUrl + "__viewer__.html", mCardContent.toString(), "text/html", "utf-8", null);
}
if (mShowTimer && mCardTimer.getVisibility() == View.INVISIBLE) {
switchTopBarVisibility(View.VISIBLE);
}
if (!sDisplayAnswer) {
updateForNewCard();
}
}
内容来源于网络,如有侵权,请联系作者删除!