JsonObject Class

A class that represents a JSON object.


Constructors

NameDescription
JsonObjectInitializes an empty JsonObject.
JsonObject(string)Initializes a JsonObject by deserializing a JSON string.

JsonObject Constructor

Creates an empty JsonObject.

JsonObject(String) Constructor

Creates a JsonObject instance by deserializing a JSON string.

Use dark colors for code blocksCopy
1
public JsonObject(String json)
Parameter nameTypeDescription
jsonStringThe json string to deserailize.

Property

PropertyProperty valueDescription
JsonObject.CountintReturns the number of members the JsonObject has.

Methods

NameDescription
JsonObject.Exists(String)Indicates if the a member with the given name exists in the JsonObject.
JsonObject.IsNull(String)Indicates if the member with the given name is null.
JsonObject.AddObject(String, Object)Adds a object as a new member of the JsonObject.
JsonObject.AddArray(String, Object[])Adds an object array as a new member of the JsonObject.
JsonObject.AddJsonObject(String, JsonObject)Adds a JsonObject as a new member of the JsonObject.
JsonObject.AddDate(String, DateTime)Adds a date as a new member of the JsonObject.
JsonObject.AddBoolean(String, Boolean)Adds a boolean as a new member of the JsonObject.
JsonObject.AddDouble(String, Double)Adds a double as a new member of the JsonObject.
JsonObject.AddString(String, String)Adds a string as a new member of the JsonObject.
JsonObject.TryGetAsDate(String, Nullable{DateTime})Returns the value of the member with the given name cast to a date.
JsonObject.TryGetArray(String, Object[])Returns the array for the member with the given name.
JsonObject.TryGetObject(String, Object)Returns the object value of the member with the given name.
JsonObject.TryGetJsonObject(String, JsonObject)Returns the JsonObject value of the member with the given name.
JsonObject.TryGetAsBoolean(String, Nullable{Boolean})Returns the value of the member with the given name cast to a bool.
JsonObject.TryGetAsLong(String, Nullable{Int64})Returns the value of the member with the given name cast to a long.
JsonObject.TryGetAsDouble(String, Nullable{Double})Returns the value of the member with the specified name cast to a double.
JsonObject.TryGetString(String, String)Returns the string value of the member with the specified name.
JsonObject.Delete(String)Deletes the member identified with the specified name.
JsonObject.ToJsonWrites the JsonObject to a JSON string.
JsonObject.GetEnumeratorReturns an enumerator that iterates through the JsonObject members

JsonObject.Exists(String) Method

Indicates if the member with the given name exists in the JsonObject. This method returns true if the member is found, false if it isn't.

Use dark colors for code blocksCopy
1
public bool Exists(string name)
Parameter nameDescription
nameThe member name to look for.

JsonObject.IsNull(String) Method

Indicates if the member with the given name is null. ArgumentOutOfRangeException will be thrown if the member doesn't exist in the JsonObject. This method returns true if the member is found, false if it isn't.

Use dark colors for code blocksCopy
1
public bool IsNull(string name)
Parameter nameDescription
nameThe member name to look for.

JsonObject.AddObject(String, Object) Method

Adds a object as a new member of the JsonObject. Use this method to add arrays of value types (e.g. double[]).

Use dark colors for code blocksCopy
1
public void AddObject(string name, object value)
Parameter nameDescription
nameThe name of the new member.
valueThe object to be added.

JsonObject.AddArray(String, Object[]) Method

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

Use dark colors for code blocksCopy
1
public void AddArray(string name, object[] objectArray)
Parameter nameDescription
nameThe name of the new member.
objectArrayThe array to be added.

JsonObject.AddJsonObject(String, JsonObject) Method

Adds a JsonObject as a new member of the JsonObject.

Use dark colors for code blocksCopy
1
public void AddJsonObject(string name, JsonObject jsonObj)
Parameter nameDescription
nameThe name of the new member.
jsonObjThe JsonObject to be added.

JsonObject.AddDate(String, DateTime) Method

Adds a date as a new member of the JsonObject.

Use dark colors for code blocksCopy
1
public void AddDate(string name, DateTime dateTime)
Parameter nameDescription
nameThe name of the new member.
dateTimeThe date to be added.

JsonObject.AddBoolean(String, Boolean) Method

Adds a boolean as a new member of the JsonObject.

Use dark colors for code blocksCopy
1
public void AddBoolean(string name, bool value)
Parameter nameDescription
nameThe name of the new member.
valueThe boolean value to be added.

JsonObject.AddLong(String, Int64) Method

Adds a long as a new member of the JsonObject.

Use dark colors for code blocksCopy
1
public void AddLong(string name, long value)
Parameter nameDescription
nameThe name of the new member.
valueThe long value to be added.

JsonObject.AddDouble(String, Double) Method

Adds a double as a new member of the JsonObject.

Use dark colors for code blocksCopy
1
public void AddDouble(string name, double value)
Parameter nameDescription
nameThe name of the new member.
valueThe double value to be added.

JsonObject.AddString(String, String) Method

Adds a string as a new member of the JsonObject.

Use dark colors for code blocksCopy
1
public void AddString(string name, string value)
Parameter nameDescription
nameThe name of the new member.
valueThe string to be added.

JsonObject.TryGetAsDate(String, Nullable{DateTime}) Method

Returns the value of the member with the given name cast to a date. This method returns true if the member was found and its value can be cast to a date, otherwise returns false.

Use dark colors for code blocksCopy
1
public bool TryGetAsDate(string name, out DateTime? dateTime)
Parameter nameDescription
nameThe name of the member to return a date for.
dateTimeThe value of the member cast to a date or null.

JsonObject.TryGetArray(String, Object[]) Method

Returns the array for the member with the given name. This method returns true if the member was found and its value is an array or null, otherwise returns false.

Use dark colors for code blocksCopy
1
public bool TryGetArray(string name, out object[] objectArray)
Parameter nameDescription
nameThe name of the member that contains the array.
objectArrayThe array being returned or null.

JsonObject.TryGetObject(String, Object) Method

Returns the object value of the member with the given name. This method returns true if the member was found (even if its value is null), otherwise returns false.

Use dark colors for code blocksCopy
1
public bool TryGetObject(string name, out object value)
Parameter nameDescription
nameThe name of the member to return.
valueThe object being returned or null.

JsonObject.TryGetJsonObject(String, JsonObject) Method

Returns the JsonObject value of the member with the given name. This method returns true if the member was found (even if its value is null), otherwise returns false.

Use dark colors for code blocksCopy
1
public bool TryGetJsonObject(string name, out JsonObject jsonObject)
Parameter nameDescription
nameThe name of the member to return.
jsonObjectThe JsonObject being returned or null.

JsonObject.TryGetAsBoolean(String, Nullable{Boolean}) Method

Returns the value of the member with the given name cast to a bool. This method returns true if the member was found and can be cast to a bool, otherwise returns false.

Use dark colors for code blocksCopy
1
public bool TryGetAsBoolean(string name, out bool? value)
Parameter nameDescription
nameThe name of the member to return.
valueThe value of the member cast to a bool or null.

JsonObject.TryGetAsLong(String, Nullable{Int64}) Method

Returns the value of the member with the given name cast to a long. This method returns true if the member was found and can be cast to a long, otherwise returns false.

Use dark colors for code blocksCopy
1
public bool TryGetAsLong(string name, out long? value)
Parameter nameDescription
nameThe name of the member to return.
valueThe value of the member cast to a long or null.

JsonObject.TryGetAsDouble(String, Nullable{Double}) Method

Returns the value of the member with the specified name cast to a double. This method returns true if the member was found and can be cast to a double, otherwise returns false.

Use dark colors for code blocksCopy
1
public bool TryGetAsDouble(string name, out double? value)
Parameter nameDescription
nameThe name of the member to return.
valueThe value of the member cast to a double or null.

JsonObject.TryGetString(String, String) Method

Returns the string value of the member with the specified name. This method returns true if the string-typed member was found (even if its value is null), otherwise returns false.

Use dark colors for code blocksCopy
1
public bool TryGetString(string name, out string value)
Parameter nameDescription
nameThe name of the member to return.
valueThe string being returned. It may be null.

JsonObject.Delete(String) Method

Deletes the member identified with the specified name.

Use dark colors for code blocksCopy
1
public void Delete(string name)
Parameter nameDescription
nameThe name of the member to delete.

JsonObject.ToJson Method

Use dark colors for code blocksCopy
1
public string ToJson()

Writes the JsonObject to a JSON string. This method returns the JSON string.

JsonObject.GetEnumerator Method

Returns an enumerator that iterates through the JsonObject members (Members are of type KeyValuePair<string, object>).

Use dark colors for code blocksCopy
1
public IEnumerator GetEnumerator()

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.