JsonArray Class

Represents a JSON array, interpreted as a list of JsonValue elements. Use the ToString or WriteTo methods to convert it to JSON.

Definition

Namespace: KGySoft.Json
Assembly: KGySoft.Json (in KGySoft.Json.dll) Version: 3.0.0
C#
[SerializableAttribute]
public sealed class JsonArray : IList<JsonValue>, 
	ICollection<JsonValue>, IEnumerable<JsonValue>, IEnumerable
Inheritance
Object    JsonArray
Implements
ICollectionJsonValue, IEnumerableJsonValue, IListJsonValue, IEnumerable

Remarks

Just like in JavaScript, the ToString (and WriteTo) methods replace Undefined values with Null.

Obtaining an element by the indexer using an invalid index returns Undefined, which is also a JavaScript-compatible behavior.

  Tip

See the Remarks section of the JsonValue type for more details and examples.

Constructors

JsonArray Initializes a new instance of the JsonArray class.
JsonArray(IEnumerableJsonValue) Initializes a new instance of the JsonArray class from a collection of JsonValue items.

Properties

Item Gets or sets the element at the specified index. When the indexer is read, using an invalid index returns Undefined, just like in JavaScript.
Length Gets the number of elements contained in the JsonArray.

Methods

Add Adds an item to the JsonArray.
Clear Removes all items from the JsonArray.
Contains Determines whether the JsonArray contains the specific item.
CopyTo Copies the elements of the JsonArray to an Array of JsonValue elements, starting at the specified arrayIndex.
Equals Determines whether the specified Object is equal to this instance. This method performs a deep comparison. Allows comparing also to JsonValue instances with Array Type.
(Overrides ObjectEquals(Object))
GetEnumerator Returns an enumerator that iterates through the JsonArray.
GetHashCode Returns a hash code for this JsonArray instance.
(Overrides ObjectGetHashCode)
IndexOf Determines the index of a specific value in the JsonArray.
Insert Inserts an item to the JsonArray at the specified index.
Parse(String) Reads a JsonArray from a string that contains JSON array.
Parse(TextReader) Reads a JsonArray from a TextReader that contains a JSON array.
Parse(Stream, Encoding) Reads a JsonArray from a Stream that contains JSON array.
Remove Removes the first occurrence of the specific item from the JsonArray.
RemoveAt Removes the value from the JsonArray at the specified index.
ToString Returns a minimized JSON string that represents this JsonArray.
(Overrides ObjectToString)
ToString(String) Returns a JSON string that represents this JsonArray.
TryParse(String, JsonArray) Tries to read a JsonArray from a string that contains JSON array.
TryParse(TextReader, JsonArray) Tries to read a JsonArray from a TextReader that contains JSON array.
TryParse(Stream, JsonArray, Encoding) Tries to read a JsonArray from a Stream that contains JSON array.
WriteTo(StringBuilder, String) Writes this JsonArray instance into a JsonArray.
WriteTo(TextWriter, String) Writes this JsonArray instance into a TextReader.
WriteTo(Stream, Encoding, String) Writes this JsonArray instance into a Stream using the specified encoding.

See Also