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

json string

The JSON document to deserialize.

Properties

Count

Returns the number of members the JsonObject has.

public int Count { get; }

Property Value

int

Methods

AddArray(string, object[])

Adds an object array as a new member of the JsonObject.

public void AddArray(string name, object[] objectArray)

Parameters

name string

The name of the new member.

objectArray object[]

The array to be added.

AddBoolean(string, bool)

Adds a boolean as a new member of the JsonObject.

public void AddBoolean(string name, bool value)

Parameters

name string

The name of the new member.

value bool

The boolean value to be added.

AddDate(string, DateTime)

Adds a date as a new member of the JsonObject.

public void AddDate(string name, DateTime dateTime)

Parameters

name string

The name of the new member.

dateTime DateTime

The date to be added.

AddDouble(string, double)

Adds a double as a new member of the JsonObject.

public void AddDouble(string name, double value)

Parameters

name string

The name of the new member.

value double

The double value to be added.

AddJsonObject(string, JsonObject)

Adds a JsonObject as a new member of the JsonObject.

public void AddJsonObject(string name, JsonObject jo)

Parameters

name string

The name of the new member.

jo JsonObject

The 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

name string

The name of the new member.

value long

The long value to be added.

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

name string

The name of the new member.

value object

The object to be added.

AddString(string, string)

Adds a string as a new member of the JsonObject.

public void AddString(string name, string value)

Parameters

name string

The name of the new member.

value string

The string to be added.

Delete(string)

Deletes the member identified with the specified name.

public void Delete(string name)

Parameters

name string

The 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

name string

The 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

name string

The 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

name string

The name of the member that contains the array.

objectArray object[]

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

name string

The name of the member to return.

value bool?

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

name string

The name of the member to return a date for.

dateTime DateTime?

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

name string

The name of the member to return.

value double?

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

name string

The name of the member to return.

value long?

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

name string

The name of the member to return.

jsonObject JsonObject

The 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

name string

The name of the member to return.

value object

The object being returned or null.

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

name string

The name of the member to return.

value string

The 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.