Language

JSONObject.PutOpt(String, Object) Method

Definition

Equivalent to put(name, value) when both parameters are non-null; does nothing otherwise.

[Android.Runtime.Register("putOpt", "(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;", "GetPutOpt_Ljava_lang_String_Ljava_lang_Object_Handler")]
public virtual Org.Json.JSONObject PutOpt(string? name, Java.Lang.Object? value);
[<Android.Runtime.Register("putOpt", "(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;", "GetPutOpt_Ljava_lang_String_Ljava_lang_Object_Handler")>]
abstract member PutOpt : string * Java.Lang.Object -> Org.Json.JSONObject
override this.PutOpt : string * Java.Lang.Object -> Org.Json.JSONObject

Parameters

name
String

The name of the mapping to set. If null, this method makes no change.

value
Object

The value to store. If it is a null reference, this method makes no change and does not remove an existing mapping. Use Null to store JSON null. Other values must satisfy Put(String, Object).

Returns

This object, whether or not a mapping was changed.

Attributes

Exceptions

Remarks

Equivalent to put(name, value) when both parameters are non-null; does nothing otherwise.

Java documentation for org.json.JSONObject.putOpt(java.lang.String, java.lang.Object).

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