Language

JSONObject.OptBoolean Method

Definition

Overloads

Name Description
OptBoolean(String)

Returns the value mapped by name if it exists and is a boolean or can be coerced to a boolean, or false otherwise.

OptBoolean(String, Boolean)

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

OptBoolean(String)

Returns the value mapped by name if it exists and is a boolean or can be coerced to a boolean, or false otherwise.

[Android.Runtime.Register("optBoolean", "(Ljava/lang/String;)Z", "GetOptBoolean_Ljava_lang_String_Handler")]
public virtual bool OptBoolean(string? name);
[<Android.Runtime.Register("optBoolean", "(Ljava/lang/String;)Z", "GetOptBoolean_Ljava_lang_String_Handler")>]
abstract member OptBoolean : string -> bool
override this.OptBoolean : string -> bool

Parameters

name
String

The name of the value to read, or null if no name is supplied.

Returns

The Boolean value, or the result of a case-insensitive comparison of a string to "true" or "false". Returns false if the mapping is missing or the value cannot be converted.

Attributes

Remarks

Returns the value mapped by name if it exists and is a boolean or can be coerced to a boolean, or false otherwise.

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

OptBoolean(String, Boolean)

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

[Android.Runtime.Register("optBoolean", "(Ljava/lang/String;Z)Z", "GetOptBoolean_Ljava_lang_String_ZHandler")]
public virtual bool OptBoolean(string? name, bool fallback);
[<Android.Runtime.Register("optBoolean", "(Ljava/lang/String;Z)Z", "GetOptBoolean_Ljava_lang_String_ZHandler")>]
abstract member OptBoolean : string * bool -> bool
override this.OptBoolean : string * bool -> bool

Parameters

name
String

The name of the value to read, or null if no name is supplied.

fallback
Boolean

The value to return if the mapping is missing or its value cannot be converted to a Boolean.

Returns

The Boolean value, including a string equal to "true" or "false" without regard to case, or fallback if conversion fails.

Attributes

Remarks

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

Java documentation for org.json.JSONObject.optBoolean(java.lang.String, boolean).

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