添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Click or drag to resize 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
Name Description
Public method JArray
Initializes a new instance of the JArray class.
Public method JArray(Object)
Initializes a new instance of the JArray class with the specified content.
Public method JArray( Object )
Initializes a new instance of the JArray class with the specified content.
Public method JArray(JArray)
Initializes a new instance of the JArray class from another JArray object.
Top
Properties
Name Description
Protected property ChildrenTokens
Gets the container's children tokens.
(Overrides JContainer ChildrenTokens .)
Public property Count
Gets the count of child JSON tokens.
(Inherited from JContainer .)
Public property First
Get the first child token of this token.
(Inherited from JContainer .)
Public property HasValues
Gets a value indicating whether this token has child tokens.
(Inherited from JContainer .)
Public property IsReadOnly
Gets a value indicating whether the JArray is read-only.
Public property Item Int32
Gets or sets the JToken at the specified index.
Public property Item Object
Gets the JToken with the specified key.
(Overrides JToken Item Object .)
Public property Last
Get the last child token of this token.
(Inherited from JContainer .)
Public property Next
Gets the next sibling token of this node.
(Inherited from JToken .)
Public property Parent
Gets or sets the parent.
(Inherited from JToken .)
Public property Path
Gets the path of the JSON token.
(Inherited from JToken .)
Public property Previous
Gets the previous sibling token of this node.
(Inherited from JToken .)
Public property Root
Gets the root JToken of this JToken .
(Inherited from JToken .)
Public property Type
Gets the node type for this JToken .
(Overrides JToken Type .)
Top
Methods
Name Description
Public method Add(Object)
Adds the specified content as children of this JToken .
(Inherited from JContainer .)
Public method Add(JToken)
Adds an item to the JArray .
Public method AddAfterSelf
Adds the specified content immediately after this token.
(Inherited from JToken .)
Public method AddAnnotation
Adds an object to the annotation list of this JToken .
(Inherited from JToken .)
Public method AddBeforeSelf
Adds the specified content immediately before this token.
(Inherited from JToken .)
Public method AddFirst
Adds the specified content as the first children of this JToken .
(Inherited from JContainer .)
Public method AfterSelf
Returns a collection of the sibling tokens after this token, in document order.
(Inherited from JToken .)
Public method Ancestors
Returns a collection of the ancestor tokens of this token.
(Inherited from JToken .)
Public method AncestorsAndSelf
Returns a collection of tokens that contain this token, and the ancestors of this token.
(Inherited from JToken .)
Public method Annotation(Type)
Gets the first annotation object of the specified type from this JToken .
(Inherited from JToken .)
Public method Annotation T
Get the first annotation object of the specified type from this JToken .
(Inherited from JToken .)
Public method Annotations(Type)
Gets a collection of annotations of the specified type for this JToken .
(Inherited from JToken .)
Public method Annotations T
Gets a collection of annotations of the specified type for this JToken .
(Inherited from JToken .)
Public method BeforeSelf
Returns a collection of the sibling tokens before this token, in document order.
(Inherited from JToken .)
Public method Children
Returns a collection of the child tokens of this token, in document order.
(Inherited from JContainer .)
Public method Clear
Removes all items from the JArray .
Public method Contains
Determines whether the JArray contains a specific value.
Public method CopyTo
Copies the elements of the JArray to an array, starting at a particular array index.
Public method CreateReader
Creates a JsonReader for this token.
(Inherited from JToken .)
Public method CreateWriter
Creates a JsonWriter that can be used to add tokens to the JToken .
(Inherited from JContainer .)
Public method DeepClone
Creates a new instance of the JToken . All child tokens are recursively cloned.
(Inherited from JToken .)
Public method Descendants
Returns a collection of the descendant tokens for this token in document order.
(Inherited from JContainer .)
Public method DescendantsAndSelf
Returns a collection of the tokens that contain this token, and all descendant tokens of this token, in document order.
(Inherited from JContainer .)
Public method Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object .)
Protected method Finalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object .)
Public method Static member FromObject(Object)
Creates a JArray from an object.
Public method Static member FromObject(Object, JsonSerializer)
Creates a JArray from an object.
Public method GetEnumerator
Returns an enumerator that iterates through the collection.
Public method GetHashCode
Serves as the default hash function.
(Inherited from Object .)
Protected method GetMetaObject
Returns the DynamicMetaObject responsible for binding operations performed on this object.
(Inherited from JToken .)
Public method GetType
Gets the Type of the current instance.
(Inherited from Object .)
Public method IndexOf
Determines the index of a specific item in the JArray .
Public method Insert
Inserts an item to the JArray at the specified index.
Public method Static member Load(JsonReader)
Loads an JArray from a JsonReader .
Public method Static member Load(JsonReader, JsonLoadSettings)
Loads an JArray from a JsonReader .
Public method Static member LoadAsync(JsonReader, CancellationToken)
Asynchronously loads a JArray from a JsonReader .
Public method Static member LoadAsync(JsonReader, JsonLoadSettings, CancellationToken)
Asynchronously loads a JArray from a JsonReader .
Protected method MemberwiseClone
Creates a shallow copy of the current Object .
(Inherited from Object .)
Public method Merge(Object)
Merge the specified content into this JToken .
(Inherited from JContainer .)
Public method Merge(Object, JsonMergeSettings)
Merge the specified content into this JToken using JsonMergeSettings .
(Inherited from JContainer .)
Protected method OnAddingNew
Raises the AddingNew event.
(Inherited from JContainer .)
Protected method OnCollectionChanged
Raises the CollectionChanged event.
(Inherited from JContainer .)
Protected method OnListChanged
Raises the ListChanged event.
(Inherited from JContainer .)
Public method Static member Code example Parse(String)
Load a JArray from a string that contains JSON.
Public method Static member Code example Parse(String, JsonLoadSettings)
Load a JArray from a string that contains JSON.
Public method Remove
Removes this token from its parent.
(Inherited from JToken .)
Public method Remove(JToken)
Removes the first occurrence of a specific object from the JArray .
Public method RemoveAll
Removes the child nodes from this token.
(Inherited from JContainer .)
Public method RemoveAnnotations(Type)
Removes the annotations of the specified type from this JToken .
(Inherited from JToken .)
Public method RemoveAnnotations T
Removes the annotations of the specified type from this JToken .
(Inherited from JToken .)
Public method RemoveAt
Removes the JArray item at the specified index.
Public method Replace
Replaces this token with the specified token.
(Inherited from JToken .)
Public method ReplaceAll
Replaces the child nodes of this token with the specified content.
(Inherited from JContainer .)
Public method SelectToken(String)
Selects a JToken using a JPath expression. Selects the token that matches the object path.
(Inherited from JToken .)
Public method SelectToken(String, Boolean)
Selects a JToken using a JPath expression. Selects the token that matches the object path.
(Inherited from JToken .)
Public method SelectTokens(String)
Selects a collection of elements using a JPath expression.
(Inherited from JToken .)
Public method SelectTokens(String, Boolean)
Selects a collection of elements using a JPath expression.
(Inherited from JToken .)
Public method ToObject(Type)
Creates an instance of the specified .NET type from the JToken .
(Inherited from JToken .)
Public method ToObject(Type, JsonSerializer)
Creates an instance of the specified .NET type from the JToken using the specified JsonSerializer .
(Inherited from JToken .)
Public method ToObject T
Creates an instance of the specified .NET type from the JToken .
(Inherited from JToken .)
Public method ToObject T (JsonSerializer)
Creates an instance of the specified .NET type from the JToken using the specified JsonSerializer .
(Inherited from JToken .)
Public method ToString
Returns the indented JSON for this token.
(Inherited from JToken .)
Public method ToString(Formatting, JsonConverter )
Returns the JSON for this token using the given formatting and converters.
(Inherited from JToken .)
Public method Value T
Gets the JToken with the specified key converted to the specified type.
(Inherited from JToken .)
Public method Values T
Returns a collection of the child values of this token, in document order.
(Inherited from JContainer .)
Public method WriteTo
Writes this token to a JsonWriter .
(Overrides JToken WriteTo(JsonWriter, JsonConverter ) .)
Public method WriteToAsync(JsonWriter, JsonConverter )
Writes this token to a JsonWriter asynchronously.
(Inherited from JToken .)
Public method WriteToAsync(JsonWriter, CancellationToken, JsonConverter )
Writes this token to a JsonWriter asynchronously.
(Overrides JToken WriteToAsync(JsonWriter, CancellationToken, JsonConverter ) .)
Top
Events
Name Description
Public event AddingNew
Occurs before an item is added to the collection.
(Inherited from JContainer .)
Public event CollectionChanged
Occurs when the items list of the collection has changed, or the collection is reset.
(Inherited from JContainer .)
Public event ListChanged
Occurs when the list changes or an item in the list changes.
(Inherited from JContainer .)
Top
Extension Methods
Name Description
Public Extension Method Ancestors JToken
Returns a collection of tokens that contains the ancestors of every token in the source collection.
(Defined by Extensions .)
Public Extension Method AncestorsAndSelf JToken
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 Method AsJEnumerable Overloaded.
Returns the input typed as IJEnumerable T .
(Defined by Extensions .)
Public Extension Method AsJEnumerable JToken Overloaded.
Returns the input typed as IJEnumerable T .
(Defined by Extensions .)
Public Extension Method Children JToken Overloaded.
Returns a collection of child tokens of every array in the source collection.
(Defined by Extensions .)
Public Extension Method Children JToken, U Overloaded.
Returns a collection of converted child tokens of every array in the source collection.
(Defined by Extensions .)
Public Extension Method IsValid(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 Method IsValid(JsonSchema, IList String ) 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 Method Validate(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 Method Validate(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 Method Value U Overloaded.
Converts the value.
(Defined by Extensions .)
Public Extension Method Value JToken, U Overloaded.
Converts the value.
(Defined by Extensions .)
Public Extension Method Values Overloaded.
Returns a collection of child values of every object in the source collection.
(Defined by Extensions .)
Public Extension Method Values(Object) Overloaded.
Returns a collection of child values of every object in the source collection with the given key.
(Defined by Extensions .)
Public Extension Method Values U Overloaded.
Returns a collection of converted child values of every object in the source collection.
(Defined by Extensions .)
Public Extension Method Values U (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 = @"[