Table of Contents

Class JArray

Namespace
Newtonsoft.Json.Linq
Assembly
Newtonsoft.Json.dll

Represents a JSON array.

public class JArray : JContainer, IJEnumerable<JToken>, IJsonLineInfo, ICloneable, ITypedList, IBindingList, IList, ICollection, IList<JToken>, ICollection<JToken>, IEnumerable<JToken>, IEnumerable
Inheritance
JArray
Implements
Inherited Members
Extension Methods

Constructors

JArray()

Initializes a new instance of the JArray class.

public JArray()

JArray(JArray)

Initializes a new instance of the JArray class from another JArray object.

public JArray(JArray other)

Parameters

other JArray

A JArray object to copy from.

JArray(object)

Initializes a new instance of the JArray class with the specified content.

public JArray(object content)

Parameters

content object

The contents of the array.

JArray(params object[])

Initializes a new instance of the JArray class with the specified content.

public JArray(params object[] content)

Parameters

content object[]

The contents of the array.

Properties

ChildrenTokens

Gets the container's children tokens.

protected override IList<JToken> ChildrenTokens { get; }

Property Value

IList<JToken>

The container's children tokens.

this[int]

Gets or sets the JToken at the specified index.

public JToken this[int index] { get; set; }

Parameters

index int

Property Value

JToken

this[object]

Gets the JToken with the specified key.

public override JToken this[object key] { get; set; }

Parameters

key object

Property Value

JToken

The JToken with the specified key.

Type

Gets the node type for this JToken.

public override JTokenType Type { get; }

Property Value

JTokenType

The type.

Methods

Add(JToken)

Adds an item to the ICollection<T>.

public void Add(JToken item)

Parameters

item JToken

The object to add to the ICollection<T>.

Exceptions

NotSupportedException

The ICollection<T> is read-only.

Clear()

Removes all items from the ICollection<T>.

public void Clear()

Exceptions

NotSupportedException

The ICollection<T> is read-only.

Contains(JToken)

Determines whether the ICollection<T> contains a specific value.

public bool Contains(JToken item)

Parameters

item JToken

The object to locate in the ICollection<T>.

Returns

bool

true if item is found in the ICollection<T>; otherwise, false.

FromObject(object)

Creates a JArray from an object.

public static JArray FromObject(object o)

Parameters

o object

The object that will be used to create JArray.

Returns

JArray

A JArray with the values of the specified object

FromObject(object, JsonSerializer)

Creates a JArray from an object.

public static JArray FromObject(object o, JsonSerializer jsonSerializer)

Parameters

o object

The object that will be used to create JArray.

jsonSerializer JsonSerializer

The JsonSerializer that will be used to read the object.

Returns

JArray

A JArray with the values of the specified object

IndexOf(JToken)

Determines the index of a specific item in the IList<T>.

public int IndexOf(JToken item)

Parameters

item JToken

The object to locate in the IList<T>.

Returns

int

The index of item if found in the list; otherwise, -1.

Insert(int, JToken)

Inserts an item to the IList<T> at the specified index.

public void Insert(int index, JToken item)

Parameters

index int

The zero-based index at which item should be inserted.

item JToken

The object to insert into the IList<T>.

Exceptions

ArgumentOutOfRangeException

index is not a valid index in the IList<T>.

NotSupportedException

The IList<T> is read-only.

Load(JsonReader)

Loads an JArray from a JsonReader.

public static JArray Load(JsonReader reader)

Parameters

reader JsonReader

A JsonReader that will be read for the content of the JArray.

Returns

JArray

A JArray that contains the JSON that was read from the specified JsonReader.

Parse(string)

Load a JArray from a string that contains JSON.

public static JArray Parse(string json)

Parameters

json string

A string that contains JSON.

Returns

JArray

A JArray populated from the string that contains JSON.

Remove(JToken)

Removes the first occurrence of a specific object from the ICollection<T>.

public bool Remove(JToken item)

Parameters

item JToken

The object to remove from the ICollection<T>.

Returns

bool

true if item was successfully removed from the ICollection<T>; otherwise, false. This method also returns false if item is not found in the original ICollection<T>.

Exceptions

NotSupportedException

The ICollection<T> is read-only.

RemoveAt(int)

Removes the IList<T> item at the specified index.

public void RemoveAt(int index)

Parameters

index int

The zero-based index of the item to remove.

Exceptions

ArgumentOutOfRangeException

index is not a valid index in the IList<T>.

NotSupportedException

The IList<T> is read-only.

WriteTo(JsonWriter, params JsonConverter[])

Writes this token to a JsonWriter.

public override void WriteTo(JsonWriter writer, params JsonConverter[] converters)

Parameters

writer JsonWriter

A JsonWriter into which this method will write.

converters JsonConverter[]

A collection of JsonConverter which will be used when writing the token.