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

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

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

JSONObject.optDouble介绍

[英]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.
[中]获取与某个键关联的可选双精度键,如果没有此类键或其值不是数字,则获取NaN。如果该值是字符串,将尝试将其作为数字计算。

代码示例

代码示例来源:origin: org.codehaus.jettison/jettison

/**
 * 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 optDouble(key, Double.NaN);
}

代码示例来源:origin: org.codehaus.jettison/com.springsource.org.codehaus.jettison

/**
 * 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 optDouble(key, Double.NaN);
}

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

double boost = jConstraint.optDouble("boost");
if(boost == Double.NaN || boost <= 0){
  StringBuilder message = new StringBuilder("The Boost of a Constraint " +

相关文章