Class JsonObject
Class represents JObject in JSON standards.
Assembly: Alachisoft.NCache.Runtime.dll
Syntax
[Serializable]
public sealed class JsonObject : JsonValueBase, IJsonObject, IEnumerable<KeyValuePair<string, JsonValueBase>>, IEnumerable
Constructors
JsonObject()
The default constructor of class JsonObject.
Declaration
public JsonObject()
JsonObject(String)
An Overloaded constructor that populates attributes by parsing given JSONObject string.
Declaration
public JsonObject(string json)
Parameters
Type | Name | Description |
---|---|---|
System.String | json | String representation of JSONObject. |
JsonObject(String, String)
Overloaded constructor which populates attributes by parsing given JSONObject string and Type.
Declaration
public JsonObject(string json, string type)
Parameters
Type | Name | Description |
---|---|---|
System.String | json | String representation of JSONObject. |
System.String | type | Type of the JSONObject. |
Properties
Count
Number of attributes in object.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Number of attributes. |
Implements
InMemorySize
In memory size of the JSONObject.
Declaration
protected override int InMemorySize { get; }
Property Value
Type | Description |
---|---|
System.Int32 | In memory size of the JSONObject. |
Overrides
Item[String]
Iterates over attributes in JSONObject.
Declaration
public JsonValueBase this[string attributeName] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | attributeName | Name of the attribute. |
Property Value
Type | Description |
---|---|
JsonValueBase | An abstract class which acts as the base class for all JSON based types in NCache. |
Implements
Size
Size of the JSONObject.
Declaration
protected override int Size { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Size of the JSONObject. |
Overrides
Type
Type of the Json object.
Declaration
public string Type { get; set; }
Property Value
Type | Description |
---|---|
System.String | Type of the Json object. |
Value
Returns instance of this object.
Declaration
public override object Value { get; }
Property Value
Type | Description |
---|---|
System.Object | An instance of this object. |
Overrides
Methods
AddAttribute(String, JsonValue)
Adds an attribute in the object.
Declaration
public void AddAttribute(string attributeName, JsonValue attributeValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | attributeName | Name of the attribute. |
JsonValue | attributeValue | JSONValue as the attribute value. |
Implements
AddAttribute(String, JsonValueBase)
Adds an attribute in the object.
Declaration
public void AddAttribute(string attributeName, JsonValueBase attributeValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | attributeName | Name of the attribute. |
JsonValueBase | attributeValue | JsonValueBase as the attribute value. |
Implements
Clear()
Removes all attributes from JSONObject.
Declaration
public void Clear()
Implements
ContainsAttribute(String)
Checks if the attribute exits.
Declaration
public bool ContainsAttribute(string attributeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | attributeName | Name of the attribute. |
Returns
Type | Description |
---|---|
System.Boolean | True, if attribute exists. |
Implements
Equals(Object)
Checks if an object is equal to the existing instance of JSONObject.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | An object to be compared. |
Returns
Type | Description |
---|---|
System.Boolean | Boolean value true or false. |
Overrides
GetAttributeNames()
Retruns collection of all the attribute names.
Declaration
public ICollection<string> GetAttributeNames()
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.String> | Collection of all the attribute names. |
Implements
GetAttributeValue(String)
Gets attribute value identified by the attribute name.
Declaration
public JsonValueBase GetAttributeValue(string attributeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | attributeName | Name of the attribute. |
Returns
Type | Description |
---|---|
JsonValueBase | Null, if doesn't exist. |
Implements
GetEnumerator()
Returns an enumerator that iterates through JSONObject attributes.
Declaration
public IEnumerator<KeyValuePair<string, JsonValueBase>> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.String, JsonValueBase>> | An enumerator that iterates through JSONObject attributes. |
RemoveAttribute(String)
Removes attribute from object on the basis of attribute name provided.
Declaration
public bool RemoveAttribute(string attributeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | attributeName | Name of the attribute. |
Returns
Type | Description |
---|---|
System.Boolean | True, if exists and removed succcessfully. |
Implements
ToString()
Returns JSONObject in string representation.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | JSONObject in string representation. |