Language

JSONArray.OptBoolean Method

Definition

Overloads

Name Description
OptBoolean(Int32)

Returns the value at index if it exists and is a boolean or can be coerced to a boolean.

OptBoolean(Int32, Boolean)

Returns the value at index if it exists and is a boolean or can be coerced to a boolean.

OptBoolean(Int32)

Returns the value at index if it exists and is a boolean or can be coerced to a boolean.

[Android.Runtime.Register("optBoolean", "(I)Z", "GetOptBoolean_IHandler")]
public virtual bool OptBoolean(int index);
[<Android.Runtime.Register("optBoolean", "(I)Z", "GetOptBoolean_IHandler")>]
abstract member OptBoolean : int -> bool
override this.OptBoolean : int -> bool

Parameters

index
Int32

The zero-based index of the value to read.

Returns

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

Attributes

Remarks

Returns the value at index if it exists and is a boolean or can be coerced to a boolean. Returns false otherwise.

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

OptBoolean(Int32, Boolean)

Returns the value at index if it exists and is a boolean or can be coerced to a boolean.

[Android.Runtime.Register("optBoolean", "(IZ)Z", "GetOptBoolean_IZHandler")]
public virtual bool OptBoolean(int index, bool fallback);
[<Android.Runtime.Register("optBoolean", "(IZ)Z", "GetOptBoolean_IZHandler")>]
abstract member OptBoolean : int * bool -> bool
override this.OptBoolean : int * bool -> bool

Parameters

index
Int32

The zero-based index of the value to read.

fallback
Boolean

The value to return if the requested value is missing, null, or 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 at index if it exists and is a boolean or can be coerced to a boolean. Returns fallback otherwise.

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