本文整理了Java中org.json.JSONObject.optFloat()
方法的一些代码示例,展示了JSONObject.optFloat()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.optFloat()
方法的具体详情如下:
包路径:org.json.JSONObject
类名称:JSONObject
方法名:optFloat
[英]Get the optional double value associated with an index. NaN is returned if there is no value for the index, or if the value is not a number and cannot be converted to a number.
[中]获取与索引关联的可选双精度值。如果索引没有值,或者该值不是数字且无法转换为数字,则返回NaN。
代码示例来源:origin: loklak/loklak_server
/**
* Get the optional double value associated with an index. NaN is returned
* if there is no value for the index, or if the value is not a number and
* cannot be converted to a number.
*
* @param key
* A key string.
* @return The value.
*/
public float optFloat(String key) {
return this.optFloat(key, Float.NaN);
}
代码示例来源:origin: b3log/latke
/**
* Get the optional double value associated with an index. NaN is returned
* if there is no value for the index, or if the value is not a number and
* cannot be converted to a number.
*
* @param key
* A key string.
* @return The value.
*/
public float optFloat(String key) {
return this.optFloat(key, Float.NaN);
}
代码示例来源:origin: org.b3log/latke
/**
* Get the optional double value associated with an index. NaN is returned
* if there is no value for the index, or if the value is not a number and
* cannot be converted to a number.
*
* @param key
* A key string.
* @return The value.
*/
public float optFloat(String key) {
return this.optFloat(key, Float.NaN);
}
代码示例来源:origin: stackoverflow.com
public class ProductLineItem {
private String name;
private int quantity;
private float price;
public MyObject( JSONObject json ) {
name = json.getString("name");
count = json.getInt("quantity");
price = json.optFloat("price");
}
}
内容来源于网络,如有侵权,请联系作者删除!