org.apache.sling.commons.json.JSONObject.getBoolean()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.apache.sling.commons.json.JSONObject.getBoolean()方法的一些代码示例,展示了JSONObject.getBoolean()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.getBoolean()方法的具体详情如下:
包路径:org.apache.sling.commons.json.JSONObject
类名称:JSONObject
方法名:getBoolean

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");

相关文章