Share via


JSONObject.OptInt Method

Definition

Overloads

OptInt(String)

Returns the value mapped by name if it exists and is an int or can be coerced to an int, or 0 otherwise.

OptInt(String, Int32)

Returns the value mapped by name if it exists and is an int or can be coerced to an int, or fallback otherwise.

OptInt(String)

Returns the value mapped by name if it exists and is an int or can be coerced to an int, or 0 otherwise.

[Android.Runtime.Register("optInt", "(Ljava/lang/String;)I", "GetOptInt_Ljava_lang_String_Handler")]
public virtual int OptInt (string? name);
[<Android.Runtime.Register("optInt", "(Ljava/lang/String;)I", "GetOptInt_Ljava_lang_String_Handler")>]
abstract member OptInt : string -> int
override this.OptInt : string -> int

Parameters

name
String

Returns

Attributes

Remarks

Returns the value mapped by name if it exists and is an int or can be coerced to an int, or 0 otherwise.

Java documentation for org.json.JSONObject.optInt(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

OptInt(String, Int32)

Returns the value mapped by name if it exists and is an int or can be coerced to an int, or fallback otherwise.

[Android.Runtime.Register("optInt", "(Ljava/lang/String;I)I", "GetOptInt_Ljava_lang_String_IHandler")]
public virtual int OptInt (string? name, int fallback);
[<Android.Runtime.Register("optInt", "(Ljava/lang/String;I)I", "GetOptInt_Ljava_lang_String_IHandler")>]
abstract member OptInt : string * int -> int
override this.OptInt : string * int -> int

Parameters

name
String
fallback
Int32

Returns

Attributes

Remarks

Returns the value mapped by name if it exists and is an int or can be coerced to an int, or fallback otherwise.

Java documentation for org.json.JSONObject.optInt(java.lang.String, int).

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