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)
public JArray(JArray other)
Parameters
JArray(object)
Initializes a new instance of the JArray class with the specified content.
public JArray(object content)
Parameters
contentobjectThe 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
contentobject[]The contents of the array.
Properties
ChildrenTokens
Gets the container's children tokens.
protected override IList<JToken> ChildrenTokens { get; }
Property Value
this[int]
Gets or sets the JToken at the specified index.
public JToken this[int index] { get; set; }
Parameters
indexint
Property Value
this[object]
Gets the JToken with the specified key.
public override JToken this[object key] { get; set; }
Parameters
keyobject
Property Value
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
itemJTokenThe 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
itemJTokenThe object to locate in the ICollection<T>.
Returns
- bool
true if
itemis found in the ICollection<T>; otherwise, false.
FromObject(object)
Creates a JArray from an object.
public static JArray FromObject(object o)
Parameters
Returns
FromObject(object, JsonSerializer)
Creates a JArray from an object.
public static JArray FromObject(object o, JsonSerializer jsonSerializer)
Parameters
oobjectThe object that will be used to create JArray.
jsonSerializerJsonSerializerThe JsonSerializer that will be used to read the object.
Returns
IndexOf(JToken)
Determines the index of a specific item in the IList<T>.
public int IndexOf(JToken item)
Parameters
Returns
- int
The index of
itemif 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
indexintThe zero-based index at which
itemshould be inserted.itemJTokenThe object to insert into the IList<T>.
Exceptions
- ArgumentOutOfRangeException
indexis 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
readerJsonReaderA 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
Returns
Remove(JToken)
Removes the first occurrence of a specific object from the ICollection<T>.
public bool Remove(JToken item)
Parameters
itemJTokenThe object to remove from the ICollection<T>.
Returns
- bool
true if
itemwas successfully removed from the ICollection<T>; otherwise, false. This method also returns false ifitemis 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
indexintThe zero-based index of the item to remove.
Exceptions
- ArgumentOutOfRangeException
indexis 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
writerJsonWriterA JsonWriter into which this method will write.
convertersJsonConverter[]A collection of JsonConverter which will be used when writing the token.