mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 16:00:51 -07:00
grr, forgot to save changes on last commit
This commit is contained in:
parent
c46774cf13
commit
fcdb8671b2
2 changed files with 22 additions and 6 deletions
|
@ -536,7 +536,7 @@ public class JSONArray implements Iterable<Object> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the optional double value associated with an index. NaN is returned
|
* Get the optional float 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
|
* if there is no value for the index, or if the value is not a number and
|
||||||
* cannot be converted to a number.
|
* cannot be converted to a number.
|
||||||
*
|
*
|
||||||
|
@ -549,7 +549,7 @@ public class JSONArray implements Iterable<Object> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the optional double value associated with an index. The defaultValue
|
* Get the optional float value associated with an index. The defaultValue
|
||||||
* is returned if there is no value for the index, or if the value is not a
|
* 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.
|
* number and cannot be converted to a number.
|
||||||
*
|
*
|
||||||
|
@ -808,6 +808,22 @@ public class JSONArray implements Iterable<Object> {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an optional {@link Number} value associated with a key, or <code>null</code>
|
||||||
|
* if there is no such key or if the value is not a number. If the value is a string,
|
||||||
|
* an attempt will be made to evaluate it as a number ({@link BigDecimal}). This method
|
||||||
|
* would be used in cases where type coercion of the number value is unwanted.
|
||||||
|
*
|
||||||
|
* @param index
|
||||||
|
* The index must be between 0 and length() - 1.
|
||||||
|
* @param defaultValue
|
||||||
|
* The default.
|
||||||
|
* @return An object which is the value.
|
||||||
|
*/
|
||||||
|
public Number optNumber(int index) {
|
||||||
|
return this.optNumber(index, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an optional {@link Number} value associated with a key, or the default if there
|
* Get an optional {@link Number} value associated with a key, or the default if there
|
||||||
* is no such key or if the value is not a number. If the value is a string,
|
* is no such key or if the value is not a number. If the value is a string,
|
||||||
|
|
|
@ -1075,8 +1075,8 @@ public class JSONObject {
|
||||||
* if there is no value for the index, or if the value is not a number and
|
* if there is no value for the index, or if the value is not a number and
|
||||||
* cannot be converted to a number.
|
* cannot be converted to a number.
|
||||||
*
|
*
|
||||||
* @param index
|
* @param key
|
||||||
* The index must be between 0 and length() - 1.
|
* A key string.
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public float optFloat(String key) {
|
public float optFloat(String key) {
|
||||||
|
@ -1088,8 +1088,8 @@ public class JSONObject {
|
||||||
* is returned if there is no value for the index, or if the value is not a
|
* 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.
|
* number and cannot be converted to a number.
|
||||||
*
|
*
|
||||||
* @param index
|
* @param key
|
||||||
* subscript
|
* A key string.
|
||||||
* @param defaultValue
|
* @param defaultValue
|
||||||
* The default value.
|
* The default value.
|
||||||
* @return The value.
|
* @return The value.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue