Click or drag to resize
Json.NET

JArray Class

 
Represents a JSON array.
Inheritance Hierarchy

Namespace:  Newtonsoft.Json.Linq
Assembly:  Newtonsoft.Json (in Newtonsoft.Json.dll) Version: 12.0.1+509643a8952ce731e0207710c429ad6e67dc43db
Syntax
C#
public class JArray : JContainer, IList<JToken>, 
	ICollection<JToken>, IEnumerable<JToken>, IEnumerable

The JArray type exposes the following members.

Constructors
  NameDescription
Public methodJArray
Initializes a new instance of the JArray class.
Public methodJArray(Object)
Initializes a new instance of the JArray class with the specified content.
Public methodJArray(Object)
Initializes a new instance of the JArray class with the specified content.
Public methodJArray(JArray)
Initializes a new instance of the JArray class from another JArray object.
Top
Properties
  NameDescription
Protected propertyChildrenTokens
Gets the container's children tokens.
(Overrides JContainerChildrenTokens.)
Public propertyCount
Gets the count of child JSON tokens.
(Inherited from JContainer.)
Public propertyFirst
Get the first child token of this token.
(Inherited from JContainer.)
Public propertyHasValues
Gets a value indicating whether this token has child tokens.
(Inherited from JContainer.)
Public propertyIsReadOnly
Gets a value indicating whether the JArray is read-only.
Public propertyItemInt32
Gets or sets the JToken at the specified index.
Public propertyItemObject
Gets the JToken with the specified key.
(Overrides JTokenItemObject.)
Public propertyLast
Get the last child token of this token.
(Inherited from JContainer.)
Public propertyNext
Gets the next sibling token of this node.
(Inherited from JToken.)
Public propertyParent
Gets or sets the parent.
(Inherited from JToken.)
Public propertyPath
Gets the path of the JSON token.
(Inherited from JToken.)
Public propertyPrevious
Gets the previous sibling token of this node.
(Inherited from JToken.)
Public propertyRoot
Gets the root JToken of this JToken.
(Inherited from JToken.)
Public propertyType
Gets the node type for this JToken.
(Overrides JTokenType.)
Top
Methods
  NameDescription
Public methodAdd(Object)
Adds the specified content as children of this JToken.
(Inherited from JContainer.)
Public methodAdd(JToken)
Adds an item to the JArray.
Public methodAddAfterSelf
Adds the specified content immediately after this token.
(Inherited from JToken.)
Public methodAddAnnotation
Adds an object to the annotation list of this JToken.
(Inherited from JToken.)
Public methodAddBeforeSelf
Adds the specified content immediately before this token.
(Inherited from JToken.)
Public methodAddFirst
Adds the specified content as the first children of this JToken.
(Inherited from JContainer.)
Public methodAfterSelf
Returns a collection of the sibling tokens after this token, in document order.
(Inherited from JToken.)
Public methodAncestors
Returns a collection of the ancestor tokens of this token.
(Inherited from JToken.)
Public methodAncestorsAndSelf
Returns a collection of tokens that contain this token, and the ancestors of this token.
(Inherited from JToken.)
Public methodAnnotation(Type)
Gets the first annotation object of the specified type from this JToken.
(Inherited from JToken.)
Public methodAnnotationT
Get the first annotation object of the specified type from this JToken.
(Inherited from JToken.)
Public methodAnnotations(Type)
Gets a collection of annotations of the specified type for this JToken.
(Inherited from JToken.)
Public methodAnnotationsT
Gets a collection of annotations of the specified type for this JToken.
(Inherited from JToken.)
Public methodBeforeSelf
Returns a collection of the sibling tokens before this token, in document order.
(Inherited from JToken.)
Public methodChildren
Returns a collection of the child tokens of this token, in document order.
(Inherited from JContainer.)
Public methodClear
Removes all items from the JArray.
Public methodContains
Determines whether the JArray contains a specific value.
Public methodCopyTo
Copies the elements of the JArray to an array, starting at a particular array index.
Public methodCreateReader
Creates a JsonReader for this token.
(Inherited from JToken.)
Public methodCreateWriter
Creates a JsonWriter that can be used to add tokens to the JToken.
(Inherited from JContainer.)
Public methodDeepClone
Creates a new instance of the JToken. All child tokens are recursively cloned.
(Inherited from JToken.)
Public methodDescendants
Returns a collection of the descendant tokens for this token in document order.
(Inherited from JContainer.)
Public methodDescendantsAndSelf
Returns a collection of the tokens that contain this token, and all descendant tokens of this token, in document order.
(Inherited from JContainer.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodStatic memberFromObject(Object)
Creates a JArray from an object.
Public methodStatic memberFromObject(Object, JsonSerializer)
Creates a JArray from an object.
Public methodGetEnumerator
Returns an enumerator that iterates through the collection.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Protected methodGetMetaObject
Returns the DynamicMetaObject responsible for binding operations performed on this object.
(Inherited from JToken.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIndexOf
Determines the index of a specific item in the JArray.
Public methodInsert
Inserts an item to the JArray at the specified index.
Public methodStatic memberLoad(JsonReader)
Loads an JArray from a JsonReader.
Public methodStatic memberLoad(JsonReader, JsonLoadSettings)
Loads an JArray from a JsonReader.
Public methodStatic memberLoadAsync(JsonReader, CancellationToken)
Asynchronously loads a JArray from a JsonReader.
Public methodStatic memberLoadAsync(JsonReader, JsonLoadSettings, CancellationToken)
Asynchronously loads a JArray from a JsonReader.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodMerge(Object)
Merge the specified content into this JToken.
(Inherited from JContainer.)
Public methodMerge(Object, JsonMergeSettings)
Merge the specified content into this JToken using JsonMergeSettings.
(Inherited from JContainer.)
Protected methodOnAddingNew
Raises the AddingNew event.
(Inherited from JContainer.)
Protected methodOnCollectionChanged
Raises the CollectionChanged event.
(Inherited from JContainer.)
Protected methodOnListChanged
Raises the ListChanged event.
(Inherited from JContainer.)
Public methodStatic memberCode exampleParse(String)
Load a JArray from a string that contains JSON.
Public methodStatic memberCode exampleParse(String, JsonLoadSettings)
Load a JArray from a string that contains JSON.
Public methodRemove
Removes this token from its parent.
(Inherited from JToken.)
Public methodRemove(JToken)
Removes the first occurrence of a specific object from the JArray.
Public methodRemoveAll
Removes the child nodes from this token.
(Inherited from JContainer.)
Public methodRemoveAnnotations(Type)
Removes the annotations of the specified type from this JToken.
(Inherited from JToken.)
Public methodRemoveAnnotationsT
Removes the annotations of the specified type from this JToken.
(Inherited from JToken.)
Public methodRemoveAt
Removes the JArray item at the specified index.
Public methodReplace
Replaces this token with the specified token.
(Inherited from JToken.)
Public methodReplaceAll
Replaces the child nodes of this token with the specified content.
(Inherited from JContainer.)
Public methodSelectToken(String)
Selects a JToken using a JPath expression. Selects the token that matches the object path.
(Inherited from JToken.)
Public methodSelectToken(String, Boolean)
Selects a JToken using a JPath expression. Selects the token that matches the object path.
(Inherited from JToken.)
Public methodSelectTokens(String)
Selects a collection of elements using a JPath expression.
(Inherited from JToken.)
Public methodSelectTokens(String, Boolean)
Selects a collection of elements using a JPath expression.
(Inherited from JToken.)
Public methodToObject(Type)
Creates an instance of the specified .NET type from the JToken.
(Inherited from JToken.)
Public methodToObject(Type, JsonSerializer)
Creates an instance of the specified .NET type from the JToken using the specified JsonSerializer.
(Inherited from JToken.)
Public methodToObjectT
Creates an instance of the specified .NET type from the JToken.
(Inherited from JToken.)
Public methodToObjectT(JsonSerializer)
Creates an instance of the specified .NET type from the JToken using the specified JsonSerializer.
(Inherited from JToken.)
Public methodToString
Returns the indented JSON for this token.
(Inherited from JToken.)
Public methodToString(Formatting, JsonConverter)
Returns the JSON for this token using the given formatting and converters.
(Inherited from JToken.)
Public methodValueT
Gets the JToken with the specified key converted to the specified type.
(Inherited from JToken.)
Public methodValuesT
Returns a collection of the child values of this token, in document order.
(Inherited from JContainer.)
Public methodWriteTo
Writes this token to a JsonWriter.
(Overrides JTokenWriteTo(JsonWriter, JsonConverter).)
Public methodWriteToAsync(JsonWriter, JsonConverter)
Writes this token to a JsonWriter asynchronously.
(Inherited from JToken.)
Public methodWriteToAsync(JsonWriter, CancellationToken, JsonConverter)
Writes this token to a JsonWriter asynchronously.
(Overrides JTokenWriteToAsync(JsonWriter, CancellationToken, JsonConverter).)
Top
Events
  NameDescription
Public eventAddingNew
Occurs before an item is added to the collection.
(Inherited from JContainer.)
Public eventCollectionChanged
Occurs when the items list of the collection has changed, or the collection is reset.
(Inherited from JContainer.)
Public eventListChanged
Occurs when the list changes or an item in the list changes.
(Inherited from JContainer.)
Top
Extension Methods
  NameDescription
Public Extension MethodAncestorsJToken
Returns a collection of tokens that contains the ancestors of every token in the source collection.
(Defined by Extensions.)
Public Extension MethodAncestorsAndSelfJToken
Returns a collection of tokens that contains every token in the source collection, and the ancestors of every token in the source collection.
(Defined by Extensions.)
Public Extension MethodAsJEnumerableOverloaded. (Defined by Extensions.)
Public Extension MethodAsJEnumerableJTokenOverloaded. (Defined by Extensions.)
Public Extension MethodChildrenJTokenOverloaded.
Returns a collection of child tokens of every array in the source collection.
(Defined by Extensions.)
Public Extension MethodChildrenJToken, UOverloaded.
Returns a collection of converted child tokens of every array in the source collection.
(Defined by Extensions.)
Public Extension MethodIsValid(JsonSchema)Overloaded.

Determines whether the JToken is valid.

Caution note Caution
JSON Schema validation has been moved to its own package. See https://www.newtonsoft.com/jsonschema for more details.
(Defined by Extensions.)
Public Extension MethodIsValid(JsonSchema, IListString)Overloaded.

Determines whether the JToken is valid.

Caution note Caution
JSON Schema validation has been moved to its own package. See https://www.newtonsoft.com/jsonschema for more details.
(Defined by Extensions.)
Public Extension MethodValidate(JsonSchema)Overloaded.

Validates the specified JToken.

Caution note Caution
JSON Schema validation has been moved to its own package. See https://www.newtonsoft.com/jsonschema for more details.
(Defined by Extensions.)
Public Extension MethodValidate(JsonSchema, ValidationEventHandler)Overloaded.

Validates the specified JToken.

Caution note Caution
JSON Schema validation has been moved to its own package. See https://www.newtonsoft.com/jsonschema for more details.
(Defined by Extensions.)
Public Extension MethodValueUOverloaded.
Converts the value.
(Defined by Extensions.)
Public Extension MethodValueJToken, UOverloaded.
Converts the value.
(Defined by Extensions.)
Public Extension MethodValuesOverloaded.
Returns a collection of child values of every object in the source collection.
(Defined by Extensions.)
Public Extension MethodValues(Object)Overloaded.
Returns a collection of child values of every object in the source collection with the given key.
(Defined by Extensions.)
Public Extension MethodValuesUOverloaded.
Returns a collection of converted child values of every object in the source collection.
(Defined by Extensions.)
Public Extension MethodValuesU(Object)Overloaded.
Returns a collection of converted child values of every object in the source collection with the given key.
(Defined by Extensions.)
Top
Examples
Parsing a JSON Array from Text
string json = @"[
  'Small',
  'Medium',
  'Large'
]";

JArray a = JArray.Parse(json);
See Also