Class JArray
Represents a JSON array.
Implements
Inherited Members
Namespace: Bayat.Json.Linq
Assembly: Bayat.Json.Runtime.dll
Syntax
public class JArray : JContainer, IJEnumerable<JToken>, IJsonLineInfo, ICloneable, IDynamicMetaObjectProvider, ITypedList, IBindingList, IList, ICollection, INotifyCollectionChanged, IList<JToken>, ICollection<JToken>, IEnumerable<JToken>, IEnumerable
Examples
Constructors
| Improve this Doc View SourceJArray()
Initializes a new instance of the JArray class.
Declaration
public JArray()
JArray(JArray)
Declaration
public JArray(JArray other)
Parameters
Type | Name | Description |
---|---|---|
JArray | other | A JArray object to copy from. |
JArray(Object)
Initializes a new instance of the JArray class with the specified content.
Declaration
public JArray(object content)
Parameters
Type | Name | Description |
---|---|---|
System.Object | content | The contents of the array. |
JArray(Object[])
Initializes a new instance of the JArray class with the specified content.
Declaration
public JArray(params object[] content)
Parameters
Type | Name | Description |
---|---|---|
System.Object[] | content | The contents of the array. |
Properties
| Improve this Doc View SourceChildrenTokens
Gets the container's children tokens.
Declaration
protected override IList<JToken> ChildrenTokens { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<JToken> | The container's children tokens. |
Overrides
| Improve this Doc View SourceIsReadOnly
Gets a value indicating whether the System.Collections.Generic.ICollection<T> is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the System.Collections.Generic.ICollection<T> is read-only; otherwise, false. |
Item[Int32]
Gets or sets the JToken at the specified index.
Declaration
public JToken this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type | Description |
---|---|
JToken |
Item[Object]
Gets the JToken with the specified key.
Declaration
public override JToken this[object key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Object | key |
Property Value
Type | Description |
---|---|
JToken | The JToken with the specified key. |
Overrides
| Improve this Doc View SourceType
Gets the node type for this JToken.
Declaration
public override JTokenType Type { get; }
Property Value
Type | Description |
---|---|
JTokenType | The type. |
Overrides
Methods
| Improve this Doc View SourceAdd(JToken)
Adds an item to the System.Collections.Generic.ICollection<T>.
Declaration
public void Add(JToken item)
Parameters
Type | Name | Description |
---|---|---|
JToken | item | The object to add to the System.Collections.Generic.ICollection<T>. |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | The System.Collections.Generic.ICollection<T> is read-only. |
Clear()
Removes all items from the System.Collections.Generic.ICollection<T>.
Declaration
public void Clear()
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | The System.Collections.Generic.ICollection<T> is read-only. |
CloneToken()
Declaration
public override JToken CloneToken()
Returns
Type | Description |
---|---|
JToken |
Overrides
| Improve this Doc View SourceContains(JToken)
Determines whether the System.Collections.Generic.ICollection<T> contains a specific value.
Declaration
public bool Contains(JToken item)
Parameters
Type | Name | Description |
---|---|---|
JToken | item | The object to locate in the System.Collections.Generic.ICollection<T>. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
CopyTo(JToken[], Int32)
Copies to.
Declaration
public void CopyTo(JToken[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
JToken[] | array | The array. |
System.Int32 | arrayIndex | Index of the array. |
DeepEquals(JToken)
Declaration
public override bool DeepEquals(JToken node)
Parameters
Type | Name | Description |
---|---|---|
JToken | node |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
| Improve this Doc View SourceFromObject(Object)
Creates a JArray from an object.
Declaration
public static JArray FromObject(object o)
Parameters
Type | Name | Description |
---|---|---|
System.Object | o | The object that will be used to create JArray. |
Returns
Type | Description |
---|---|
JArray | A JArray with the values of the specified object |
FromObject(Object, JsonSerializer)
Creates a JArray from an object.
Declaration
public static JArray FromObject(object o, JsonSerializer jsonSerializer)
Parameters
Type | Name | Description |
---|---|---|
System.Object | o | The object that will be used to create JArray. |
JsonSerializer | jsonSerializer | The JsonSerializer that will be used to read the object. |
Returns
Type | Description |
---|---|
JArray | A JArray with the values of the specified object |
GetDeepHashCode()
Declaration
public override int GetDeepHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
| Improve this Doc View SourceGetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<JToken> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<JToken> | A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the collection. |
IndexOf(JToken)
Determines the index of a specific item in the System.Collections.Generic.IList<T>.
Declaration
public int IndexOf(JToken item)
Parameters
Type | Name | Description |
---|---|---|
JToken | item | The object to locate in the System.Collections.Generic.IList<T>. |
Returns
Type | Description |
---|---|
System.Int32 | The index of |
IndexOfItem(JToken)
Declaration
public override int IndexOfItem(JToken item)
Parameters
Type | Name | Description |
---|---|---|
JToken | item |
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
| Improve this Doc View SourceInsert(Int32, JToken)
Inserts an item to the System.Collections.Generic.IList<T> at the specified index.
Declaration
public void Insert(int index, JToken item)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index at which |
JToken | item | The object to insert into the System.Collections.Generic.IList<T>. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
System.NotSupportedException | The System.Collections.Generic.IList<T> is read-only. |
Load(JsonReader)
Loads an JArray from a JsonReader.
Declaration
public static JArray Load(JsonReader reader)
Parameters
Type | Name | Description |
---|---|---|
JsonReader | reader | A JsonReader that will be read for the content of the JArray. |
Returns
Type | Description |
---|---|
JArray | A JArray that contains the JSON that was read from the specified JsonReader. |
Load(JsonReader, JsonLoadSettings)
Loads an JArray from a JsonReader.
Declaration
public static JArray Load(JsonReader reader, JsonLoadSettings settings)
Parameters
Type | Name | Description |
---|---|---|
JsonReader | reader | A JsonReader that will be read for the content of the JArray. |
JsonLoadSettings | settings | The JsonLoadSettings used to load the JSON. If this is null, default load settings will be used. |
Returns
Type | Description |
---|---|
JArray | A JArray that contains the JSON that was read from the specified JsonReader. |
MergeItem(Object, JsonMergeSettings)
Declaration
public override void MergeItem(object content, JsonMergeSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.Object | content | |
JsonMergeSettings | settings |
Overrides
| Improve this Doc View SourceParse(String)
Load a JArray from a string that contains JSON.
Declaration
public static JArray Parse(string json)
Parameters
Type | Name | Description |
---|---|---|
System.String | json | A System.String that contains JSON. |
Returns
Type | Description |
---|---|
JArray | A JArray populated from the string that contains JSON. |
Examples
|
Improve this Doc
View Source
Parse(String, JsonLoadSettings)
Load a JArray from a string that contains JSON.
Declaration
public static JArray Parse(string json, JsonLoadSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.String | json | A System.String that contains JSON. |
JsonLoadSettings | settings | The JsonLoadSettings used to load the JSON. If this is null, default load settings will be used. |
Returns
Type | Description |
---|---|
JArray | A JArray populated from the string that contains JSON. |
Examples
|
Improve this Doc
View Source
Remove(JToken)
Removes the first occurrence of a specific object from the System.Collections.Generic.ICollection<T>.
Declaration
public bool Remove(JToken item)
Parameters
Type | Name | Description |
---|---|---|
JToken | item | The object to remove from the System.Collections.Generic.ICollection<T>. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | The System.Collections.Generic.ICollection<T> is read-only. |
RemoveAt(Int32)
Removes the System.Collections.Generic.IList<T> item at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the item to remove. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
System.NotSupportedException | The System.Collections.Generic.IList<T> is read-only. |
WriteTo(JsonWriter, JsonConverter[])
Writes this token to a JsonWriter.
Declaration
public override void WriteTo(JsonWriter writer, params JsonConverter[] converters)
Parameters
Type | Name | Description |
---|---|---|
JsonWriter | writer | A JsonWriter into which this method will write. |
JsonConverter[] | converters | A collection of JsonConverter which will be used when writing the token. |