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
content
objectThe 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
this[int]
Gets or sets the JToken at the specified index.
public JToken this[int index] { get; set; }
Parameters
index
int
Property Value
this[object]
Gets the JToken with the specified key.
public override JToken this[object key] { get; set; }
Parameters
key
object
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
item
JTokenThe 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
JTokenThe 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
Returns
FromObject(object, JsonSerializer)
Creates a JArray from an object.
public static JArray FromObject(object o, JsonSerializer jsonSerializer)
Parameters
o
objectThe object that will be used to create JArray.
jsonSerializer
JsonSerializerThe 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
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
intThe zero-based index at which
item
should be inserted.item
JTokenThe 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
JsonReaderA 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
item
JTokenThe 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 ifitem
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
intThe 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
JsonWriterA JsonWriter into which this method will write.
converters
JsonConverter[]A collection of JsonConverter which will be used when writing the token.