JSONObject.OptLong Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| OptLong(String) |
Returns the value mapped by |
| OptLong(String, Int64) |
Returns the value mapped by |
OptLong(String)
Returns the value mapped by name if it exists and is a long or
can be coerced to a long, or 0 otherwise.
[Android.Runtime.Register("optLong", "(Ljava/lang/String;)J", "GetOptLong_Ljava_lang_String_Handler")]
public virtual long OptLong(string? name);
[<Android.Runtime.Register("optLong", "(Ljava/lang/String;)J", "GetOptLong_Ljava_lang_String_Handler")>]
abstract member OptLong : string -> int64
override this.OptLong : string -> int64
Parameters
- name
- String
The name of the value to read, or null if no name is supplied.
Returns
The number converted to a long integer, or 0 if the mapping is missing or the value cannot be converted. Numeric strings are parsed as Java doubles and then cast to long integers; this can lose precision for large values.
- Attributes
Remarks
Returns the value mapped by name if it exists and is a long or can be coerced to a long, or 0 otherwise. Note that JSON represents numbers as doubles, so this is lossy; use strings to transfer numbers via JSON.
Java documentation for org.json.JSONObject.optLong(java.lang.String).
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
OptLong(String, Int64)
Returns the value mapped by name if it exists and is a long or
can be coerced to a long, or fallback otherwise.
[Android.Runtime.Register("optLong", "(Ljava/lang/String;J)J", "GetOptLong_Ljava_lang_String_JHandler")]
public virtual long OptLong(string? name, long fallback);
[<Android.Runtime.Register("optLong", "(Ljava/lang/String;J)J", "GetOptLong_Ljava_lang_String_JHandler")>]
abstract member OptLong : string * int64 -> int64
override this.OptLong : string * int64 -> int64
Parameters
- name
- String
The name of the value to read, or null if no name is supplied.
- fallback
- Int64
The value to return if the mapping is missing or its value cannot be converted to a long integer.
Returns
The number converted to a long integer, or fallback if conversion fails. Numeric strings are parsed as Java doubles and then cast to long integers; this can lose precision for large values.
- Attributes
Remarks
Returns the value mapped by name if it exists and is a long or can be coerced to a long, or fallback otherwise. Note that JSON represents numbers as doubles, so this is lossy; use strings to transfer numbers via JSON.
Java documentation for org.json.JSONObject.optLong(java.lang.String, long).
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.