JSONArray.OptString 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 |
|---|---|
| OptString(Int32) |
Returns the value at |
| OptString(Int32, String) |
Returns the value at |
OptString(Int32)
Returns the value at index if it exists, coercing it if
necessary.
[Android.Runtime.Register("optString", "(I)Ljava/lang/String;", "GetOptString_IHandler")]
public virtual string? OptString(int index);
[<Android.Runtime.Register("optString", "(I)Ljava/lang/String;", "GetOptString_IHandler")>]
abstract member OptString : int -> string
override this.OptString : int -> string
Parameters
- index
- Int32
The zero-based index of the value to read.
Returns
The value converted to a string, or the empty string if the value is missing or is a null reference. Null converts to "null".
- Attributes
Remarks
Returns the value at index if it exists, coercing it if necessary. Returns the empty string if no such value exists.
Java documentation for org.json.JSONArray.optString(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
OptString(Int32, String)
Returns the value at index if it exists, coercing it if
necessary.
[Android.Runtime.Register("optString", "(ILjava/lang/String;)Ljava/lang/String;", "GetOptString_ILjava_lang_String_Handler")]
public virtual string? OptString(int index, string? fallback);
[<Android.Runtime.Register("optString", "(ILjava/lang/String;)Ljava/lang/String;", "GetOptString_ILjava_lang_String_Handler")>]
abstract member OptString : int * string -> string
override this.OptString : int * string -> string
Parameters
- index
- Int32
The zero-based index of the value to read.
- fallback
- String
The string, which can be null, to return if the requested value is missing or is a null reference.
Returns
The value converted to a string, or fallback if the value is missing or is a null reference. Null converts to "null", not the fallback.
- Attributes
Remarks
Returns the value at index if it exists, coercing it if necessary. Returns fallback if no such value exists.
Java documentation for org.json.JSONArray.optString(int, 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.