A class that represents a JSON object.
Constructors
Name | Description |
---|---|
JsonObject | Initializes 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.
public JsonObject(String json)
Parameter name | Type | Description |
---|---|---|
json | String | The json string to deserailize. |
Property
Property | Property value | Description |
---|---|---|
JsonObject.Count | int | Returns the number of members the JsonObject has. |
Methods
Name | Description |
---|---|
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.ToJson | Writes the JsonObject to a JSON string. |
JsonObject.GetEnumerator | Returns 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.
public bool Exists(string name)
Parameter name | Description |
---|---|
name | The member name to look for. |
JsonObject.IsNull(String) Method
Indicates if the member with the given name is null. Argument
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.
public bool IsNull(string name)
Parameter name | Description |
---|---|
name | The 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[]).
public void AddObject(string name, object value)
Parameter name | Description |
---|---|
name | The name of the new member. |
value | The object to be added. |
JsonObject.AddArray(String, Object[]) Method
Adds an object array as a new member of the JsonObject.
public void AddArray(string name, object[] objectArray)
Parameter name | Description |
---|---|
name | The name of the new member. |
objectArray | The array to be added. |
JsonObject.AddJsonObject(String, JsonObject) Method
Adds a JsonObject as a new member of the JsonObject.
public void AddJsonObject(string name, JsonObject jsonObj)
Parameter name | Description |
---|---|
name | The name of the new member. |
jsonObj | The JsonObject to be added. |
JsonObject.AddDate(String, DateTime) Method
Adds a date as a new member of the JsonObject.
public void AddDate(string name, DateTime dateTime)
Parameter name | Description |
---|---|
name | The name of the new member. |
dateTime | The date to be added. |
JsonObject.AddBoolean(String, Boolean) Method
Adds a boolean as a new member of the JsonObject.
public void AddBoolean(string name, bool value)
Parameter name | Description |
---|---|
name | The name of the new member. |
value | The boolean value to be added. |
JsonObject.AddLong(String, Int64) Method
Adds a long as a new member of the JsonObject.
public void AddLong(string name, long value)
Parameter name | Description |
---|---|
name | The name of the new member. |
value | The long value to be added. |
JsonObject.AddDouble(String, Double) Method
Adds a double as a new member of the JsonObject.
public void AddDouble(string name, double value)
Parameter name | Description |
---|---|
name | The name of the new member. |
value | The double value to be added. |
JsonObject.AddString(String, String) Method
Adds a string as a new member of the JsonObject.
public void AddString(string name, string value)
Parameter name | Description |
---|---|
name | The name of the new member. |
value | The 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.
public bool TryGetAsDate(string name, out DateTime? dateTime)
Parameter name | Description |
---|---|
name | The name of the member to return a date for. |
dateTime | The 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.
public bool TryGetArray(string name, out object[] objectArray)
Parameter name | Description |
---|---|
name | The name of the member that contains the array. |
objectArray | The 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.
public bool TryGetObject(string name, out object value)
Parameter name | Description |
---|---|
name | The name of the member to return. |
value | The 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.
public bool TryGetJsonObject(string name, out JsonObject jsonObject)
Parameter name | Description |
---|---|
name | The name of the member to return. |
jsonObject | The 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.
public bool TryGetAsBoolean(string name, out bool? value)
Parameter name | Description |
---|---|
name | The name of the member to return. |
value | The 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.
public bool TryGetAsLong(string name, out long? value)
Parameter name | Description |
---|---|
name | The name of the member to return. |
value | The 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.
public bool TryGetAsDouble(string name, out double? value)
Parameter name | Description |
---|---|
name | The name of the member to return. |
value | The 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.
public bool TryGetString(string name, out string value)
Parameter name | Description |
---|---|
name | The name of the member to return. |
value | The string being returned. It may be null. |
JsonObject.Delete(String) Method
Deletes the member identified with the specified name.
public void Delete(string name)
Parameter name | Description |
---|---|
name | The name of the member to delete. |
JsonObject.ToJson Method
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>).
public IEnumerator GetEnumerator()