KGy SOFT

JsonArray Class

KGy SOFT JSON Libraries Help
Represents a JSON array, interpreted as a list of JsonValue elements. Use the ToString or WriteTo methods to convert it to JSON.
See the Remarks section for details.
Inheritance Hierarchy

SystemObject
  KGySoft.JsonJsonArray

Namespace:  KGySoft.Json
Assembly:  KGySoft.Json (in KGySoft.Json.dll) Version: 2.0.0
Syntax

[SerializableAttribute]
public sealed class JsonArray : IList<JsonValue>, 
	ICollection<JsonValue>, IEnumerable<JsonValue>, IEnumerable

The JsonArray type exposes the following members.

Constructors

  NameDescription
Public methodJsonArray
Initializes a new instance of the JsonArray class.
Public methodJsonArray(IEnumerableJsonValue)
Initializes a new instance of the JsonArray class from a collection of JsonValue items.
Top
Properties

  NameDescription
Public propertyItem
Gets or sets the element at the specified index. When the indexer is read, using an invalid index returns Undefined, just like in JavaScript.
Public propertyLength
Gets the number of elements contained in the JsonArray.
Top
Methods

  NameDescription
Public methodAdd
Adds an item to the JsonArray.
Public methodClear
Removes all items from the JsonArray.
Public methodContains
Determines whether the JsonArray contains the specific item.
Public methodCopyTo
Copies the elements of the JsonArray to an Array of JsonValue elements, starting at the specified arrayIndex.
Public methodEquals
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).)
Public methodGetEnumerator
Returns an enumerator that iterates through the JsonArray.
Public methodGetHashCode
Returns a hash code for this JsonArray instance.
(Overrides ObjectGetHashCode.)
Public methodIndexOf
Determines the index of a specific value in the JsonArray.
Public methodInsert
Inserts an item to the JsonArray at the specified index.
Public methodStatic memberParse(String)
Reads a JsonArray from a string that contains JSON array.
Public methodStatic memberParse(TextReader)
Reads a JsonArray from a TextReader that contains a JSON array.
Public methodStatic memberParse(Stream, Encoding)
Reads a JsonArray from a Stream that contains JSON array.
Public methodRemove
Removes the first occurrence of the specific item from the JsonArray.
Public methodRemoveAt
Removes the value from the JsonArray at the specified index.
Public methodToString
Returns a minimized JSON string that represents this JsonArray.
(Overrides ObjectToString.)
Public methodToString(String)
Returns a JSON string that represents this JsonArray.
Public methodStatic memberTryParse(String, JsonArray)
Tries to read a JsonArray from a string that contains JSON array.
Public methodStatic memberTryParse(TextReader, JsonArray)
Tries to read a JsonArray from a TextReader that contains JSON array.
Public methodStatic memberTryParse(Stream, JsonArray, Encoding)
Tries to read a JsonArray from a Stream that contains JSON array.
Public methodWriteTo(StringBuilder, String)
Writes this JsonArray instance into a JsonArray.
Public methodWriteTo(TextWriter, String)
Writes this JsonArray instance into a TextReader.
Public methodWriteTo(Stream, Encoding, String)
Writes this JsonArray instance into a Stream using the specified encoding.
Top
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 Tip
See the Remarks section of the JsonValue type for more details and examples.
See Also

Reference