Class JsonArray
A JSON array containing JsonValues.
Inherited Members
Namespace: Subsembly.Json
Assembly: Subsembly.Json.dll
Syntax
public class JsonArray : JsonValue, ICloneable, IEnumerable<JsonValue>, ICollection, IEnumerable
Constructors
JsonArray()
Creates a new, mutable JsonArray.
Declaration
public JsonArray()
JsonArray(IEnumerable<string>)
Creates a new JsonArray initialized with the given string array.
Declaration
public JsonArray(IEnumerable<string> vsValues)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<string> | vsValues | Collection of strings that will be added to the newly created array. |
JsonArray(IList<JsonValue>)
Creates a new JsonArray using a given collection.
Declaration
public JsonArray(IList<JsonValue> aValue)
Parameters
Type | Name | Description |
---|---|---|
IList<JsonValue> | aValue | Collection of values. This must not be |
Properties
Count
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
Value
Declaration
public IList<JsonValue> Value { get; }
Property Value
Type | Description |
---|---|
IList<JsonValue> |
Methods
Add(JsonValue)
Add another JSON data element to the end of this array.
Declaration
public void Add(JsonValue aValue)
Parameters
Type | Name | Description |
---|---|---|
JsonValue | aValue |
AddRange(IEnumerable<JsonValue>)
Declaration
public void AddRange(IEnumerable<JsonValue> vJsonValues)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<JsonValue> | vJsonValues |
OnAfterParseArray()
This is called by the JSON parser after this array object was fully parsed. It can be used as a hook to validate the data, or to prepare a cache.
Declaration
protected virtual void OnAfterParseArray()
Remarks
The default implementation does nothing.
OnCreateChildArray(int)
This is called whenever the JSON parser needs a child array object for this object.
Declaration
protected virtual JsonArray OnCreateChildArray(int nIndex)
Parameters
Type | Name | Description |
---|---|---|
int | nIndex | The index position at which a child array object is needed. |
Returns
Type | Description |
---|---|
JsonArray |
Remarks
An override can use this as an opportunity to returned a more specific object, derived from JsonArray. Such a derived object could provide additional convenient properties for accessing the fields of it.
The default implementation just returns a new JsonArray.
OnCreateChildObject(int)
This is called whenever the JSON parser needs a child object for this array.
Declaration
protected virtual JsonObject OnCreateChildObject(int nIndex)
Parameters
Type | Name | Description |
---|---|---|
int | nIndex | The index position at which a child object is needed. |
Returns
Type | Description |
---|---|
JsonObject |
Remarks
An override can use this as an opportunity to returned a more specific object, derived from JsonObject. Such a derived object could provide additional convenient properties for accessing the fields of it.
The default implementation just returns a new JsonObject.
Parse(byte[])
Declaration
public static JsonArray Parse(byte[] vbJson)
Parameters
Type | Name | Description |
---|---|---|
byte[] | vbJson |
Returns
Type | Description |
---|---|
JsonArray |
Parse(string)
Declaration
public static JsonArray Parse(string sJson)
Parameters
Type | Name | Description |
---|---|---|
string | sJson |
Returns
Type | Description |
---|---|
JsonArray |
ParseJson(byte[])
Parse the given vbJson
data, adding all its objects and values
to this array.
Declaration
public void ParseJson(byte[] vbJson)
Parameters
Type | Name | Description |
---|---|---|
byte[] | vbJson | The JSON to be parsed. If this is is |
ParseJson(string)
Parse the given sJson
string, adding all its objects and values
to this array.
Declaration
public void ParseJson(string sJson)
Parameters
Type | Name | Description |
---|---|---|
string | sJson | The JSON to be parsed. If this is is |
Remarks
This JsonArray will receive all the parsed object. The object will be added to this array.
ToArray<T>()
Declaration
public T[] ToArray<T>() where T : JsonValue
Returns
Type | Description |
---|---|
T[] |
Type Parameters
Name | Description |
---|---|
T |
ToStringArray()
Declaration
public string[] ToStringArray()
Returns
Type | Description |
---|---|
string[] |