Click or drag to resize
Json.NET

JToken Class

 
Represents an abstract JSON token.
Inheritance Hierarchy

Namespace:  Newtonsoft.Json.Linq
Assembly:  Newtonsoft.Json (in Newtonsoft.Json.dll) Version: 12.0.1+509643a8952ce731e0207710c429ad6e67dc43db
Syntax
C#
public abstract class JToken : IJEnumerable<JToken>, 
	IEnumerable<JToken>, IEnumerable, IJsonLineInfo, ICloneable, 
	IDynamicMetaObjectProvider

The JToken type exposes the following members.

Properties
  NameDescription
Public propertyStatic memberEqualityComparer
Gets a comparer that can compare two tokens for value equality.
Public propertyFirst
Get the first child token of this token.
Public propertyHasValues
Gets a value indicating whether this token has child tokens.
Public propertyItem
Gets the JToken with the specified key.
Public propertyLast
Get the last child token of this token.
Public propertyNext
Gets the next sibling token of this node.
Public propertyParent
Gets or sets the parent.
Public propertyPath
Gets the path of the JSON token.
Public propertyPrevious
Gets the previous sibling token of this node.
Public propertyRoot
Gets the root JToken of this JToken.
Public propertyType
Gets the node type for this JToken.
Top
Methods
  NameDescription
Public methodAddAfterSelf
Adds the specified content immediately after this token.
Public methodAddAnnotation
Adds an object to the annotation list of this JToken.
Public methodAddBeforeSelf
Adds the specified content immediately before this token.
Public methodAfterSelf
Returns a collection of the sibling tokens after this token, in document order.
Public methodAncestors
Returns a collection of the ancestor tokens of this token.
Public methodAncestorsAndSelf
Returns a collection of tokens that contain this token, and the ancestors of this token.
Public methodAnnotation(Type)
Gets the first annotation object of the specified type from this JToken.
Public methodAnnotationT
Get the first annotation object of the specified type from this JToken.
Public methodAnnotations(Type)
Gets a collection of annotations of the specified type for this JToken.
Public methodAnnotationsT
Gets a collection of annotations of the specified type for this JToken.
Public methodBeforeSelf
Returns a collection of the sibling tokens before this token, in document order.
Public methodChildren
Returns a collection of the child tokens of this token, in document order.
Public methodChildrenT
Returns a collection of the child tokens of this token, in document order, filtered by the specified type.
Public methodCreateReader
Creates a JsonReader for this token.
Public methodDeepClone
Creates a new instance of the JToken. All child tokens are recursively cloned.
Public methodStatic memberDeepEquals
Compares the values of two tokens, including the values of all descendant tokens.
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 JToken from an object.
Public methodStatic memberFromObject(Object, JsonSerializer)
Creates a JToken from an object using the specified JsonSerializer.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Protected methodGetMetaObject
Returns the DynamicMetaObject responsible for binding operations performed on this object.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberLoad(JsonReader)
Creates a JToken from a JsonReader.
Public methodStatic memberLoad(JsonReader, JsonLoadSettings)
Creates a JToken from a JsonReader.
Public methodStatic memberLoadAsync(JsonReader, CancellationToken)
Asynchronously creates a JToken from a JsonReader.
Public methodStatic memberLoadAsync(JsonReader, JsonLoadSettings, CancellationToken)
Asynchronously creates a JToken from a JsonReader.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodStatic memberParse(String)
Load a JToken from a string that contains JSON.
Public methodStatic memberParse(String, JsonLoadSettings)
Load a JToken from a string that contains JSON.
Public methodStatic memberReadFrom(JsonReader)
Creates a JToken from a JsonReader.
Public methodStatic memberReadFrom(JsonReader, JsonLoadSettings)
Creates a JToken from a JsonReader.
Public methodStatic memberReadFromAsync(JsonReader, CancellationToken)
Asynchronously creates a JToken from a JsonReader.
Public methodStatic memberReadFromAsync(JsonReader, JsonLoadSettings, CancellationToken)
Asynchronously creates a JToken from a JsonReader.
Public methodRemove
Removes this token from its parent.
Public methodRemoveAnnotations(Type)
Removes the annotations of the specified type from this JToken.
Public methodRemoveAnnotationsT
Removes the annotations of the specified type from this JToken.
Public methodReplace
Replaces this token with the specified token.
Public methodSelectToken(String)
Selects a JToken using a JPath expression. Selects the token that matches the object path.
Public methodSelectToken(String, Boolean)
Selects a JToken using a JPath expression. Selects the token that matches the object path.
Public methodSelectTokens(String)
Selects a collection of elements using a JPath expression.
Public methodSelectTokens(String, Boolean)
Selects a collection of elements using a JPath expression.
Public methodToObject(Type)
Creates an instance of the specified .NET type from the JToken.
Public methodToObject(Type, JsonSerializer)
Creates an instance of the specified .NET type from the JToken using the specified JsonSerializer.
Public methodToObjectT
Creates an instance of the specified .NET type from the JToken.
Public methodToObjectT(JsonSerializer)
Creates an instance of the specified .NET type from the JToken using the specified JsonSerializer.
Public methodToString
Returns the indented JSON for this token.
(Overrides ObjectToString.)
Public methodToString(Formatting, JsonConverter)
Returns the JSON for this token using the given formatting and converters.
Public methodValueT
Gets the JToken with the specified key converted to the specified type.
Public methodValuesT
Returns a collection of the child values of this token, in document order.
Public methodWriteTo
Writes this token to a JsonWriter.
Public methodWriteToAsync(JsonWriter, JsonConverter)
Writes this token to a JsonWriter asynchronously.
Public methodWriteToAsync(JsonWriter, CancellationToken, JsonConverter)
Writes this token to a JsonWriter asynchronously.
Top
Operators
  NameDescription
Public operatorStatic member(JToken to Boolean)
Performs an explicit conversion from JToken to Boolean.
Public operatorStatic member(JToken to DateTimeOffset)
Performs an explicit conversion from JToken to DateTimeOffset.
Public operatorStatic member(JToken to NullableBoolean)
Public operatorStatic member(JToken to Int64)
Public operatorStatic member(JToken to NullableDateTime)
Public operatorStatic member(JToken to NullableDateTimeOffset)
Public operatorStatic member(JToken to NullableDecimal)
Public operatorStatic member(JToken to NullableDouble)
Public operatorStatic member(JToken to NullableChar)
Public operatorStatic member(JToken to Int32)
Performs an explicit conversion from JToken to Int32.
Public operatorStatic member(JToken to Int16)
Performs an explicit conversion from JToken to Int16.
Public operatorStatic member(JToken to UInt16)
Performs an explicit conversion from JToken to UInt16.
Public operatorStatic member(JToken to Char)
Performs an explicit conversion from JToken to Char.
Public operatorStatic member(JToken to Byte)
Performs an explicit conversion from JToken to Byte.
Public operatorStatic member(JToken to SByte)
Performs an explicit conversion from JToken to SByte.
Public operatorStatic member(JToken to NullableInt32)
Public operatorStatic member(JToken to NullableInt16)
Public operatorStatic member(JToken to NullableUInt16)
Public operatorStatic member(JToken to NullableByte)
Public operatorStatic member(JToken to NullableSByte)
Public operatorStatic member(JToken to DateTime)
Public operatorStatic member(JToken to NullableInt64)
Public operatorStatic member(JToken to NullableSingle)
Public operatorStatic member(JToken to Decimal)
Performs an explicit conversion from JToken to Decimal.
Public operatorStatic member(JToken to NullableUInt32)
Public operatorStatic member(JToken to NullableUInt64)
Public operatorStatic member(JToken to Double)
Performs an explicit conversion from JToken to Double.
Public operatorStatic member(JToken to Single)
Performs an explicit conversion from JToken to Single.
Public operatorStatic member(JToken to String)
Performs an explicit conversion from JToken to String.
Public operatorStatic member(JToken to UInt32)
Performs an explicit conversion from JToken to UInt32.
Public operatorStatic member(JToken to UInt64)
Performs an explicit conversion from JToken to UInt64.
Public operatorStatic member(JToken to Byte)
Performs an explicit conversion from JToken to Byte[].
Public operatorStatic member(JToken to Guid)
Performs an explicit conversion from JToken to Guid.
Public operatorStatic member(JToken to NullableGuid)
Public operatorStatic member(JToken to TimeSpan)
Performs an explicit conversion from JToken to TimeSpan.
Public operatorStatic member(JToken to NullableTimeSpan)
Public operatorStatic member(JToken to Uri)
Performs an explicit conversion from JToken to Uri.
Public operatorStatic member(Boolean to JToken)
Performs an implicit conversion from Boolean to JToken.
Public operatorStatic member(Byte to JToken)
Performs an implicit conversion from Byte to JToken.
Public operatorStatic member(Byte to JToken)
Performs an implicit conversion from Byte[] to JToken.
Public operatorStatic member(DateTime to JToken)
Performs an implicit conversion from DateTime to JToken.
Public operatorStatic member(DateTimeOffset to JToken)
Performs an implicit conversion from DateTimeOffset to JToken.
Public operatorStatic member(Decimal to JToken)
Performs an implicit conversion from Decimal to JToken.
Public operatorStatic member(Double to JToken)
Performs an implicit conversion from Double to JToken.
Public operatorStatic member(Guid to JToken)
Performs an implicit conversion from Guid to JToken.
Public operatorStatic member(Int16 to JToken)
Performs an implicit conversion from Int16 to JToken.
Public operatorStatic member(Int32 to JToken)
Performs an implicit conversion from Int32 to JToken.
Public operatorStatic member(Int64 to JToken)
Public operatorStatic member(NullableBoolean to JToken)
Public operatorStatic member(NullableByte to JToken)
Public operatorStatic member(NullableDateTime to JToken)
Public operatorStatic member(NullableDateTimeOffset to JToken)
Public operatorStatic member(NullableDecimal to JToken)
Public operatorStatic member(NullableDouble to JToken)
Public operatorStatic member(NullableGuid to JToken)
Public operatorStatic member(NullableInt16 to JToken)
Public operatorStatic member(NullableInt32 to JToken)
Public operatorStatic member(NullableInt64 to JToken)
Public operatorStatic member(NullableSByte to JToken)
Public operatorStatic member(NullableSingle to JToken)
Public operatorStatic member(NullableTimeSpan to JToken)
Public operatorStatic member(NullableUInt16 to JToken)
Public operatorStatic member(NullableUInt32 to JToken)
Public operatorStatic member(NullableUInt64 to JToken)
Public operatorStatic member(SByte to JToken)
Performs an implicit conversion from SByte to JToken.
Public operatorStatic member(Single to JToken)
Performs an implicit conversion from Single to JToken.
Public operatorStatic member(String to JToken)
Performs an implicit conversion from String to JToken.
Public operatorStatic member(TimeSpan to JToken)
Performs an implicit conversion from TimeSpan to JToken.
Public operatorStatic member(UInt16 to JToken)
Performs an implicit conversion from UInt16 to JToken.
Public operatorStatic member(UInt32 to JToken)
Performs an implicit conversion from UInt32 to JToken.
Public operatorStatic member(UInt64 to JToken)
Performs an implicit conversion from UInt64 to JToken.
Public operatorStatic member(Uri to JToken)
Performs an implicit conversion from Uri to JToken.
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
See Also