org.json.JSONObject.optDouble()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(167)

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

JSONObject.optDouble介绍

[英]Returns the value mapped by name if it exists and is a double or can be coerced to a double. Returns NaN otherwise.
[中]返回按名称映射的值(如果该值存在且为双精度值或可以强制为双精度值)。否则返回NaN。

代码示例

代码示例来源:origin: google/physical-web

/**
 * Get extra double 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 double optExtraDouble(String key, double defaultValue) {
 return mExtraData.optDouble(key, defaultValue);
}

代码示例来源:origin: google/physical-web

/**
 * Get extra double 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 double optExtraDouble(String key, double defaultValue) {
 return mExtraData.optDouble(key, defaultValue);
}

代码示例来源:origin: google/physical-web

/**
 * Get extra double value.
 * @param key The key of the stored value.
 * @return The stored value or 0 if it doesn't exist in specified form.
 */
public double optExtraDouble(String key) {
 return mExtraData.optDouble(key);
}

代码示例来源:origin: google/physical-web

/**
 * Get extra double value.
 * @param key The key of the stored value.
 * @return The stored value or 0 if it doesn't exist in specified form.
 */
public double optExtraDouble(String key) {
 return mExtraData.optDouble(key);
}

代码示例来源:origin: zzz40500/GsonFormat

/**
 * Get an optional double associated with a key, or NaN if there is no such
 * key or if its value is not a number. If the value is a string, an attempt
 * will be made to evaluate it as a number.
 *
 * @param key
 *            A string which is the key.
 * @return An object which is the value.
 */
public double optDouble(String key) {
  return this.optDouble(key, Double.NaN);
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the value mapped by {@code name} if it exists and is a double or
 * can be coerced to a double. Returns {@code NaN} otherwise.
 */
public double optDouble(String name) {
  return optDouble(name, Double.NaN);
}

代码示例来源:origin: apache/geode

/**
 * Returns the value mapped by {@code name} if it exists and is a double or can be coerced to a
 * double, or {@code NaN} otherwise.
 *
 * @param name The name of the field we want.
 * @return The selected value if it exists.
 */
public double optDouble(String name) {
 return optDouble(name, Double.NaN);
}

代码示例来源:origin: loklak/loklak_server

/**
 * Get an optional double associated with a key, or NaN if there is no such
 * key or if its value is not a number. If the value is a string, an attempt
 * will be made to evaluate it as a number.
 *
 * @param key
 *            A string which is the key.
 * @return An object which is the value.
 */
public double optDouble(String key) {
  return this.optDouble(key, Double.NaN);
}

代码示例来源:origin: apache/geode

public double getDouble(String key) {
 return jsonObject.optDouble(key);
}

代码示例来源:origin: alibaba/Tangram-Android

public double optDoubleParam(String key) {
  if (extras.has(key))
    return extras.optDouble(key);
  if (style != null && style.extras != null)
    return style.extras.optDouble(key);
  return Double.NaN;
}

代码示例来源:origin: alibaba/Tangram-Android

public double optDoubleParam(String key) {
  if (extras.has(key)) {
    return extras.optDouble(key);
  }
  if (style != null && style.extras != null) {
    return style.extras.optDouble(key);
  }
  return Double.NaN;
}

代码示例来源:origin: ankidroid/Anki-Android

/** Integer interval after interval factor and prev+1 constraints applied */
private int _constrainedIvl(int ivl, JSONObject conf, double prev) {
  double newIvl = ivl;
  newIvl = ivl * conf.optDouble("ivlFct",1.0);
  return (int) Math.max(newIvl, prev + 1);
}

代码示例来源:origin: facebook/facebook-android-sdk

public LatLng getPosition() {
  JSONObject location = jsonData.optJSONObject(LOCATION);
  if (location != null) {
    if (location.has("latitude") && location.has("longitude")) {
      double latitude = location.optDouble("latitude");
      double longitude = location.optDouble("longitude");
      return new LatLng(latitude, longitude);
    }
  }
  return null;
}

代码示例来源:origin: alibaba/Tangram-Android

aspectRatio = (float) data.optDouble(KEY_ASPECT_RATIO);
double ratio = data.optDouble(KEY_RATIO);
if (!Double.isNaN(ratio)) {
  aspectRatio = (float)ratio;

代码示例来源:origin: alibaba/Tangram-Android

cell.setIndicatorMargin(Style.parseSize(data.optString(ATTR_INDICATOR_MARGIN), 0));
cell.setIndicatorHeight(Style.parseSize(data.optString(ATTR_INDICATOR_HEIGHT), 0));
cell.setPageWidth(data.optDouble(ATTR_PAGE_WIDTH));
cell.sethGap(Style.parseSize(data.optString(ATTR_HGAP), 0));
cell.itemRatio = data.optDouble(BannerCard.ATTR_ITEM_RATIO, Double.NaN);
cell.itemMargin[0] = Style.parseSize(data.optString(ATTR_ITEM_MARGIN_LEFT), 0);
cell.itemMargin[1] = Style.parseSize(data.optString(ATTR_ITEM_MARGIN_RIGHT), 0);

代码示例来源:origin: ankidroid/Anki-Android

r.put("ivlFct", r.optDouble("ivlFct", 1));
if (r.has("ivlfct")) {
  r.remove("ivlfct");

代码示例来源:origin: b3log/latke

/**
 * Get an optional double associated with a key, or NaN if there is no such
 * key or if its value is not a number. If the value is a string, an attempt
 * will be made to evaluate it as a number.
 *
 * @param key
 *            A string which is the key.
 * @return An object which is the value.
 */
public double optDouble(String key) {
  return this.optDouble(key, Double.NaN);
}

代码示例来源:origin: google/santa-tracker-android

public static ColoredRectangleActor fromJSON(JSONObject json) throws JSONException {
  String type = json.getString(Actor.TYPE_KEY);
  Vector2D position =
      Vector2D.get((float) json.optDouble(X_KEY, 0), (float) json.optDouble(Y_KEY, 0));
  Vector2D dimens =
      Vector2D.get(
          (float) json.optDouble(DIMENS_X_KEY, 0),
          (float) json.optDouble(DIMENS_Y_KEY, 0));
  return new ColoredRectangleActor(position, dimens, type);
}

代码示例来源:origin: RaiMan/SikuliX2

private void init(JSONObject jElement) {
 if (jElement.has("type") && "ELEMENT".equals(jElement.getString("type"))) {
  x = jElement.optInt("x", 0);
  y = jElement.optInt("y", 0);
  h = jElement.optInt("h", -1);
  w = jElement.optInt("w", -1);
  score = jElement.optDouble("score", -1);
  if (!jElement.isNull("name")) {
   name = jElement.getString("name");
  }
  if (!jElement.isNull("lastMatch")) {
   lastMatch = new Element();
   JSONObject jLastMatch = jElement.getJSONObject("lastMatch");
   lastMatch.x = jLastMatch.optInt("x", 0);
   lastMatch.y = jLastMatch.optInt("y", 0);
   lastMatch.h = jLastMatch.optInt("h", -1);
   lastMatch.w = jLastMatch.optInt("w", -1);
   lastMatch.score = jLastMatch.optDouble("score", 0);
  }
 } else {
  log.error("new (JSONObject jElement): not super-type ELEMENT: %s", jElement);
 }
}

代码示例来源:origin: andforce/iBeebo

public Buttons(JSONObject json) {
  this.pic = json.optString("pic");
  this.subType = json.optDouble("sub_type");
  this.showLoading = json.optDouble("show_loading");
  this.type = json.optString("type");
  this.name = json.optString("name");
  this.params = new Params(json.optJSONObject("params"));
}

相关文章

微信公众号

最新文章

更多

JSONObject类方法