本文整理了Java中org.apache.sling.commons.json.JSONObject.getBoolean()
方法的一些代码示例,展示了JSONObject.getBoolean()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.getBoolean()
方法的具体详情如下:
包路径:org.apache.sling.commons.json.JSONObject
类名称:JSONObject
方法名:getBoolean
[英]Get the boolean value associated with a key.
[中]获取与键关联的布尔值。
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* Get an optional boolean associated with a key.
* It returns the defaultValue if there is no such key, or if it is not
* a Boolean or the String "true" or "false" (case insensitive).
*
* @param key A key string.
* @param defaultValue The default.
* @return The truth.
*/
public boolean optBoolean(String key, boolean defaultValue) {
try {
return getBoolean(key);
} catch (Exception e) {
return defaultValue;
}
}
代码示例来源:origin: io.wcm/io.wcm.caconfig.editor
private Object toSingle(JSONObject properties, String propertyName, Class propertyType) throws JSONException {
if (propertyType.equals(String.class)) {
return properties.getString(propertyName);
}
else if (propertyType.equals(int.class)) {
return properties.getInt(propertyName);
}
else if (propertyType.equals(long.class)) {
return properties.getLong(propertyName);
}
else if (propertyType.equals(double.class)) {
return properties.getDouble(propertyName);
}
else if (propertyType.equals(boolean.class)) {
return properties.getBoolean(propertyName);
}
else {
throw new IllegalArgumentException("Unexpected type: " + propertyType.getName());
}
}
代码示例来源:origin: nateyolles/publick-sling-blog
JSONObject jsonObject = new JSONObject(responseString);
if (jsonObject.getBoolean(RECAPTCHA_SUCCESS)) {
validated = true;
代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle
for (int i = 0; i < results.length(); i++) {
JSONObject result = results.getJSONObject(i);
if (result.getBoolean("final")) {
JSONObject firstAlternative = result.getJSONArray("alternatives").getJSONObject(0);
String line = firstAlternative.getString("transcript");
内容来源于网络,如有侵权,请联系作者删除!