Class JsonObject
- Namespace
- ESRI.Server.SOESupport
- Assembly
- ESRI.Server.SOESupport.dll
Represents a JSON object as a DOM tree. This class is superseded by JsonObject.
public sealed class JsonObject : IEnumerable
- Inheritance
-
JsonObject
- Implements
- Inherited Members
Constructors
JsonObject()
Creates an empty JsonObject.
public JsonObject()
JsonObject(string)
Creates a JsonObject instance by deserializing a JSON string.
public JsonObject(string json)
Parameters
jsonstringThe JSON document to deserialize.
Properties
Count
Returns the number of members the JsonObject has.
public int Count { get; }
Property Value
Methods
AddArray(string, object[])
Adds an object array as a new member of the JsonObject.
public void AddArray(string name, object[] objectArray)
Parameters
AddBoolean(string, bool)
Adds a boolean as a new member of the JsonObject.
public void AddBoolean(string name, bool value)
Parameters
AddDate(string, DateTime)
Adds a date as a new member of the JsonObject.
public void AddDate(string name, DateTime dateTime)
Parameters
AddDouble(string, double)
Adds a double as a new member of the JsonObject.
public void AddDouble(string name, double value)
Parameters
AddJsonObject(string, JsonObject)
Adds a JsonObject as a new member of the JsonObject.
public void AddJsonObject(string name, JsonObject jo)
Parameters
namestringThe name of the new member.
joJsonObjectThe JsonObject to be added.
AddLong(string, long)
Adds a long as a new member of the JsonObject.
public void AddLong(string name, long value)
Parameters
AddObject(string, object)
Adds an object as a new member of the JsonObject. Use this method to add arrays of value types, such as double[].
public void AddObject(string name, object value)
Parameters
AddString(string, string)
Adds a string as a new member of the JsonObject.
public void AddString(string name, string value)
Parameters
Delete(string)
Deletes the member identified with the specified name.
public void Delete(string name)
Parameters
namestringThe name of the member to delete.
Exists(string)
Indicates whether a member with the given name exists in the JsonObject.
public bool Exists(string name)
Parameters
namestringThe member name to look for.
Returns
- bool
True if the member is found, False if it isn't.
GetEnumerator()
Returns an enumerator that iterates through the JsonObject members (Members are of type KeyValuePair<string, object>)
public IEnumerator GetEnumerator()
Returns
- IEnumerator
IEnumerator
IsNull(string)
Indicates if the member with the given name is null. ArgumentOutOfRangeException will be thrown if the member doesn't exist in the JsonObject.
public bool IsNull(string name)
Parameters
namestringThe name of the member to look for.
Returns
- bool
True if the member is found, False if it isn't.
ToJson()
Writes the JsonObject to a JSON string.
public string ToJson()
Returns
- string
The JSON string.
TryGetArray(string, out object[])
Returns the array for the member with the given name.
public bool TryGetArray(string name, out object[] objectArray)
Parameters
namestringThe name of the member that contains the array.
objectArrayobject[]The array being returned or null.
Returns
- bool
True if the member was found and its value is an array or null. False otherwise.
TryGetAsBoolean(string, out bool?)
Returns the value of the member with the given name cast to a bool.
public bool TryGetAsBoolean(string name, out bool? value)
Parameters
namestringThe name of the member to return.
valuebool?The value of the member cast to a bool or null.
Returns
- bool
True if the member was found and can be cast to a bool. False otherwise.
TryGetAsDate(string, out DateTime?)
Returns the value of the member with the given name cast to a date.
public bool TryGetAsDate(string name, out DateTime? dateTime)
Parameters
namestringThe name of the member to return a date for.
dateTimeDateTime?The value of the member cast to a date or null.
Returns
- bool
True if the member was found and its value can be cast to a date. False otherwise.
TryGetAsDouble(string, out double?)
Returns the value of the member with the specified name cast to a double.
public bool TryGetAsDouble(string name, out double? value)
Parameters
namestringThe name of the member to return.
valuedouble?The value of the member cast to a double or null.
Returns
- bool
True if the member was found and can be cast to a double. False otherwise.
TryGetAsLong(string, out long?)
Returns the value of the member with the given name cast to a long.
public bool TryGetAsLong(string name, out long? value)
Parameters
namestringThe name of the member to return.
valuelong?The value of the member cast to a long or null.
Returns
- bool
True if the member was found and can be cast to a long. False otherwise.
TryGetJsonObject(string, out JsonObject)
Returns the JsonObject value of the member with the given name.
public bool TryGetJsonObject(string name, out JsonObject jsonObject)
Parameters
namestringThe name of the member to return.
jsonObjectJsonObjectThe JsonObject being returned or null.
Returns
- bool
True if the member was found (even if its value is null). False otherwise.
TryGetObject(string, out object)
Returns the object value of the member with the given name.
public bool TryGetObject(string name, out object value)
Parameters
Returns
- bool
True if the member was found (even if its value is null). False otherwise.
TryGetString(string, out string)
Returns the string value of the member with the specified name.
public bool TryGetString(string name, out string value)
Parameters
namestringThe name of the member to return.
valuestringThe string being returned. It may be null.
Returns
- bool
True if the string-typed member was found (even if its value is null). False otherwise.