Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class Newtonsoft.​Json.​Linq.​JObject
Assembly: Newtonsoft.Json
Inheritance: object → JToken → JContainer → JObject
Implemented Interfaces
- IJEnumerable`1 (Inherits: System.​Collections.​Generic.​IEnumerable<​JToken>System.​Collections.​IEnumerable) Implemented by: JToken
- IJsonLineInfo Implemented by: JToken
- System.​Dynamic.​IDynamicMetaObjectProvider Implemented by: JToken
- System.​Collections.​Generic.​IList`1 (Inherits: ICollection<​Newtonsoft.​Json.​Linq.​JToken>IEnumerable<​Newtonsoft.​Json.​Linq.​JToken>IEnumerable) Implemented by: JContainer
- System.​Collections.​IList (Inherits: ICollectionIEnumerable) Implemented by: JContainer
- System.​Collections.​Specialized.​INotifyCollectionChanged Implemented by: JContainer
- System.​Collections.​Generic.​IDictionary`2 (Inherits: ICollection<​KeyValuePair<​string, Newtonsoft.​Json.​Linq.​JToken>>IEnumerable<​KeyValuePair<​string, Newtonsoft.​Json.​Linq.​JToken>>IEnumerable)
- System.​ComponentModel.​INotifyPropertyChanged
Represents a JSON object.
Properties
protected
System.​Collections.​Generic.​IList<​JToken>
ChildrenTokens
Gets the container's children tokens.
public
JTokenType
Type
Gets the node type for this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
public
JToken
Item
public
JToken
Item
public
bool
HasValues
Gets a value indicating whether this token has child tokens.
public
JToken
First
Get the first child token of this token.
public
JToken
Last
Get the last child token of this token.
public
int
Count
Gets the count of child JSON tokens.
public
JContainer
Parent
Gets or sets the parent.
public
JToken
Root
Gets the root <see cref="T:Newtonsoft.Json.Linq.JToken" /> of this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
public
JToken
Next
Gets the next sibling token of this node.
public
JToken
Previous
Gets the previous sibling token of this node.
public
string
Path
Gets the path of the JSON token.
Methods
WriteToAsync​(JsonWriter writer,
System.​Threading.​CancellationToken cancellationToken,
JsonConverter[] converters)
Writes this token to a <see cref="T:Newtonsoft.Json.JsonWriter" /> asynchronously.
Returns A <see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous write operation.
writer
A <see cref="T:Newtonsoft.Json.JsonWriter" /> into which this method will write.
cancellationToken
The token to monitor for cancellation requests.
converters
A collection of <see cref="T:Newtonsoft.Json.JsonConverter" /> which will be used when writing the token.
public static
System.​Threading.​Tasks.​Task<​JObject>
LoadAsync​(JsonReader reader,
System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously loads a <see cref="T:Newtonsoft.Json.Linq.JObject" /> from a <see cref="T:Newtonsoft.Json.JsonReader" /> .
Returns A <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous load. The <see cref="P:System.Threading.Tasks.Task`1.Result" />
property returns a <see cref="T:Newtonsoft.Json.Linq.JObject" /> that contains the JSON that was read from the specified <see cref="T:Newtonsoft.Json.JsonReader" /> .
reader
A <see cref="T:Newtonsoft.Json.JsonReader" /> that will be read for the content of the <see cref="T:Newtonsoft.Json.Linq.JObject" /> .
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
public static
System.​Threading.​Tasks.​Task<​JObject>
LoadAsync​(JsonReader reader,
JsonLoadSettings settings,
System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously loads a <see cref="T:Newtonsoft.Json.Linq.JObject" /> from a <see cref="T:Newtonsoft.Json.JsonReader" /> .
Returns A <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous load. The <see cref="P:System.Threading.Tasks.Task`1.Result" />
property returns a <see cref="T:Newtonsoft.Json.Linq.JObject" /> that contains the JSON that was read from the specified <see cref="T:Newtonsoft.Json.JsonReader" /> .
reader
A <see cref="T:Newtonsoft.Json.JsonReader" /> that will be read for the content of the <see cref="T:Newtonsoft.Json.Linq.JObject" /> .
settings
The <see cref="T:Newtonsoft.Json.Linq.JsonLoadSettings" /> used to load the JSON.
If this is <c>null</c> , default load settings will be used.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
public
System.​Collections.​Generic.​IEnumerable<​JProperty>
Properties​()
Gets an <see cref="T:System.Collections.Generic.IEnumerable`1" /> of <see cref="T:Newtonsoft.Json.Linq.JProperty" /> of this object's properties.
Returns An <see cref="T:System.Collections.Generic.IEnumerable`1" /> of <see cref="T:Newtonsoft.Json.Linq.JProperty" /> of this object's properties.
public
JProperty
Property​(string name)
Gets a <see cref="T:Newtonsoft.Json.Linq.JProperty" /> the specified name.
Returns A <see cref="T:Newtonsoft.Json.Linq.JProperty" /> with the specified name or <c>null</c> .
name
The property name.
public
JEnumerable<​JToken>
PropertyValues​()
Gets a <see cref="T:Newtonsoft.Json.Linq.JEnumerable`1" /> of <see cref="T:Newtonsoft.Json.Linq.JToken" /> of this object's property values.
Returns A <see cref="T:Newtonsoft.Json.Linq.JEnumerable`1" /> of <see cref="T:Newtonsoft.Json.Linq.JToken" /> of this object's property values.
public static
JObject
Load​(JsonReader reader)
Loads a <see cref="T:Newtonsoft.Json.Linq.JObject" /> from a <see cref="T:Newtonsoft.Json.JsonReader" /> .
Returns A <see cref="T:Newtonsoft.Json.Linq.JObject" /> that contains the JSON that was read from the specified <see cref="T:Newtonsoft.Json.JsonReader" /> .
reader
A <see cref="T:Newtonsoft.Json.JsonReader" /> that will be read for the content of the <see cref="T:Newtonsoft.Json.Linq.JObject" /> .
public static
JObject
Load​(JsonReader reader,
JsonLoadSettings settings)
Loads a <see cref="T:Newtonsoft.Json.Linq.JObject" /> from a <see cref="T:Newtonsoft.Json.JsonReader" /> .
Returns A <see cref="T:Newtonsoft.Json.Linq.JObject" /> that contains the JSON that was read from the specified <see cref="T:Newtonsoft.Json.JsonReader" /> .
reader
A <see cref="T:Newtonsoft.Json.JsonReader" /> that will be read for the content of the <see cref="T:Newtonsoft.Json.Linq.JObject" /> .
settings
The <see cref="T:Newtonsoft.Json.Linq.JsonLoadSettings" /> used to load the JSON.
If this is <c>null</c> , default load settings will be used.
public static
JObject
Parse​(string json)
Load a <see cref="T:Newtonsoft.Json.Linq.JObject" /> from a string that contains JSON.
Returns A <see cref="T:Newtonsoft.Json.Linq.JObject" /> populated from the string that contains JSON.
json
A <see cref="T:System.String" /> that contains JSON.
public static
JObject
Parse​(string json,
JsonLoadSettings settings)
Load a <see cref="T:Newtonsoft.Json.Linq.JObject" /> from a string that contains JSON.
Returns A <see cref="T:Newtonsoft.Json.Linq.JObject" /> populated from the string that contains JSON.
json
A <see cref="T:System.String" /> that contains JSON.
settings
The <see cref="T:Newtonsoft.Json.Linq.JsonLoadSettings" /> used to load the JSON.
If this is <c>null</c> , default load settings will be used.
public static
JObject
FromObject​(object o)
Creates a <see cref="T:Newtonsoft.Json.Linq.JObject" /> from an object.
Returns A <see cref="T:Newtonsoft.Json.Linq.JObject" /> with the values of the specified object.
o
The object that will be used to create <see cref="T:Newtonsoft.Json.Linq.JObject" /> .
public static
JObject
FromObject​(object o,
JsonSerializer jsonSerializer)
Creates a <see cref="T:Newtonsoft.Json.Linq.JObject" /> from an object.
Returns A <see cref="T:Newtonsoft.Json.Linq.JObject" /> with the values of the specified object.
o
The object that will be used to create <see cref="T:Newtonsoft.Json.Linq.JObject" /> .
jsonSerializer
The <see cref="T:Newtonsoft.Json.JsonSerializer" /> that will be used to read the object.
public
void
WriteTo​(JsonWriter writer,
JsonConverter[] converters)
Writes this token to a <see cref="T:Newtonsoft.Json.JsonWriter" /> .
writer
A <see cref="T:Newtonsoft.Json.JsonWriter" /> into which this method will write.
converters
A collection of <see cref="T:Newtonsoft.Json.JsonConverter" /> which will be used when writing the token.
public
JToken
GetValue​(string propertyName)
Gets the <see cref="T:Newtonsoft.Json.Linq.JToken" /> with the specified property name.
Returns The <see cref="T:Newtonsoft.Json.Linq.JToken" /> with the specified property name.
propertyName
Name of the property.
public
JToken
GetValue​(string propertyName,
System.​StringComparison comparison)
Gets the <see cref="T:Newtonsoft.Json.Linq.JToken" /> with the specified property name.
The exact property name will be searched for first and if no matching property is found then
the <see cref="T:System.StringComparison" /> will be used to match a property.
Returns The <see cref="T:Newtonsoft.Json.Linq.JToken" /> with the specified property name.
propertyName
Name of the property.
comparison
One of the enumeration values that specifies how the strings will be compared.
public
bool
TryGetValue​(string propertyName,
System.​StringComparison comparison,
JToken& value)
public
void
Add​(string propertyName,
JToken value)
Adds the specified property name.
propertyName
Name of the property.
value
The value.
public
bool
Remove​(string propertyName)
Removes the property with the specified name.
Returns <c>true</c> if item was successfully removed; otherwise, <c>false</c> .
propertyName
Name of the property.
public
System.​Collections.​Generic.​IEnumerator<​System.​Collections.​Generic.​KeyValuePair<​string, JToken>>
GetEnumerator​()
Returns an enumerator that can be used to iterate through the collection.
Returns A <see cref="T:System.Collections.Generic.IEnumerator`1" /> that can be used to iterate through the collection.
protected
void
OnPropertyChanged​(string propertyName)
Raises the <see cref="E:Newtonsoft.Json.Linq.JObject.PropertyChanged" /> event with the provided arguments.
propertyName
Name of the property.
GetMetaObject​(System.​Linq.​Expressions.​Expression parameter)
Returns the <see cref="T:System.Dynamic.DynamicMetaObject" /> responsible for binding operations performed on this object.
Returns The <see cref="T:System.Dynamic.DynamicMetaObject" /> to bind this object.
parameter
The expression tree representation of the runtime value.
protected
void
OnCollectionChanged​(System.​Collections.​Specialized.​NotifyCollectionChangedEventArgs e)
Inherited from JContainer
Raises the <see cref="E:Newtonsoft.Json.Linq.JContainer.CollectionChanged" /> event.
e
The <see cref="T:System.Collections.Specialized.NotifyCollectionChangedEventArgs" /> instance containing the event data.
public
JEnumerable<​JToken>
Children​()
Inherited from JContainer
Returns a collection of the child tokens of this token, in document order.
Returns An <see cref="T:System.Collections.Generic.IEnumerable`1" /> of <see cref="T:Newtonsoft.Json.Linq.JToken" /> containing the child tokens of this <see cref="T:Newtonsoft.Json.Linq.JToken" /> , in document order.
public
System.​Collections.​Generic.​IEnumerable<​T>
Values​()
Inherited from JContainer
Returns a collection of the child values of this token, in document order.
Returns A <see cref="T:System.Collections.Generic.IEnumerable`1" /> containing the child values of this <see cref="T:Newtonsoft.Json.Linq.JToken" /> , in document order.
public
System.​Collections.​Generic.​IEnumerable<​JToken>
Descendants​()
Inherited from JContainer
Returns a collection of the descendant tokens for this token in document order.
Returns An <see cref="T:System.Collections.Generic.IEnumerable`1" /> of <see cref="T:Newtonsoft.Json.Linq.JToken" /> containing the descendant tokens of the <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
public
System.​Collections.​Generic.​IEnumerable<​JToken>
DescendantsAndSelf​()
Inherited from JContainer
Returns a collection of the tokens that contain this token, and all descendant tokens of this token, in document order.
Returns An <see cref="T:System.Collections.Generic.IEnumerable`1" /> of <see cref="T:Newtonsoft.Json.Linq.JToken" /> containing this token, and all the descendant tokens of the <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
public
void
Add​(object content)
Inherited from JContainer
Adds the specified content as children of this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
content
The content to be added.
public
void
AddFirst​(object content)
Inherited from JContainer
Adds the specified content as the first children of this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
content
The content to be added.
public
JsonWriter
CreateWriter​()
Inherited from JContainer
Creates a <see cref="T:Newtonsoft.Json.JsonWriter" /> that can be used to add tokens to the <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
Returns A <see cref="T:Newtonsoft.Json.JsonWriter" /> that is ready to have content written to it.
public
void
ReplaceAll​(object content)
Inherited from JContainer
Replaces the child nodes of this token with the specified content.
content
The content.
public
void
RemoveAll​()
Inherited from JContainer
Removes the child nodes from this token.
public
void
Merge​(object content)
Inherited from JContainer
Merge the specified content into this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
content
The content to be merged.
public
void
Merge​(object content,
JsonMergeSettings settings)
Inherited from JContainer
Merge the specified content into this <see cref="T:Newtonsoft.Json.Linq.JToken" /> using <see cref="T:Newtonsoft.Json.Linq.JsonMergeSettings" /> .
content
The content to be merged.
settings
The <see cref="T:Newtonsoft.Json.Linq.JsonMergeSettings" /> used to merge the content.
WriteToAsync​(JsonWriter writer,
JsonConverter[] converters)
Inherited from JToken
Writes this token to a <see cref="T:Newtonsoft.Json.JsonWriter" /> asynchronously.
Returns A <see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous write operation.
writer
A <see cref="T:Newtonsoft.Json.JsonWriter" /> into which this method will write.
converters
A collection of <see cref="T:Newtonsoft.Json.JsonConverter" /> which will be used when writing the token.
public
void
AddAfterSelf​(object content)
Inherited from JToken
Adds the specified content immediately after this token.
content
A content object that contains simple content or a collection of content objects to be added after this token.
public
void
AddBeforeSelf​(object content)
Inherited from JToken
Adds the specified content immediately before this token.
content
A content object that contains simple content or a collection of content objects to be added before this token.
public
System.​Collections.​Generic.​IEnumerable<​JToken>
Ancestors​()
Inherited from JToken
Returns a collection of the ancestor tokens of this token.
Returns A collection of the ancestor tokens of this token.
public
System.​Collections.​Generic.​IEnumerable<​JToken>
AncestorsAndSelf​()
Inherited from JToken
Returns a collection of tokens that contain this token, and the ancestors of this token.
Returns A collection of tokens that contain this token, and the ancestors of this token.
public
System.​Collections.​Generic.​IEnumerable<​JToken>
AfterSelf​()
Inherited from JToken
Returns a collection of the sibling tokens after this token, in document order.
Returns A collection of the sibling tokens after this tokens, in document order.
public
System.​Collections.​Generic.​IEnumerable<​JToken>
BeforeSelf​()
Inherited from JToken
Returns a collection of the sibling tokens before this token, in document order.
Returns A collection of the sibling tokens before this token, in document order.
public
T
Value​(object key)
Inherited from JToken
Gets the <see cref="T:Newtonsoft.Json.Linq.JToken" /> with the specified key converted to the specified type.
Returns The converted token value.
key
The token key.
public
JEnumerable<​T>
Children​()
Inherited from JToken
Returns a collection of the child tokens of this token, in document order, filtered by the specified type.
Returns A <see cref="T:Newtonsoft.Json.Linq.JEnumerable`1" /> containing the child tokens of this <see cref="T:Newtonsoft.Json.Linq.JToken" /> , in document order.
public
void
Replace​(JToken value)
Inherited from JToken
Replaces this token with the specified token.
value
The value.
public
string
ToString​()
Inherited from JToken
Returns the indented JSON for this token.
Returns The indented JSON for this token.
public
string
ToString​(Formatting formatting,
JsonConverter[] converters)
Inherited from JToken
Returns the JSON for this token using the given formatting and converters.
Returns The JSON for this token using the given formatting and converters.
formatting
Indicates how the output should be formatted.
converters
A collection of <see cref="T:Newtonsoft.Json.JsonConverter" /> s which will be used when writing the token.
public
JsonReader
CreateReader​()
Inherited from JToken
Creates a <see cref="T:Newtonsoft.Json.JsonReader" /> for this token.
Returns A <see cref="T:Newtonsoft.Json.JsonReader" /> that can be used to read this token and its descendants.
public
T
ToObject​()
Inherited from JToken
Creates an instance of the specified .NET type from the <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
Returns The new object created from the JSON value.
public
object
ToObject​(System.​Type objectType)
Inherited from JToken
Creates an instance of the specified .NET type from the <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
Returns The new object created from the JSON value.
objectType
The object type that the token will be deserialized to.
public
T
ToObject​(JsonSerializer jsonSerializer)
Inherited from JToken
Creates an instance of the specified .NET type from the <see cref="T:Newtonsoft.Json.Linq.JToken" /> using the specified <see cref="T:Newtonsoft.Json.JsonSerializer" /> .
Returns The new object created from the JSON value.
jsonSerializer
The <see cref="T:Newtonsoft.Json.JsonSerializer" /> that will be used when creating the object.
public
object
ToObject​(System.​Type objectType,
JsonSerializer jsonSerializer)
Inherited from JToken
Creates an instance of the specified .NET type from the <see cref="T:Newtonsoft.Json.Linq.JToken" /> using the specified <see cref="T:Newtonsoft.Json.JsonSerializer" /> .
Returns The new object created from the JSON value.
objectType
The object type that the token will be deserialized to.
jsonSerializer
The <see cref="T:Newtonsoft.Json.JsonSerializer" /> that will be used when creating the object.
public
JToken
SelectToken​(string path)
Inherited from JToken
Selects a <see cref="T:Newtonsoft.Json.Linq.JToken" /> using a JPath expression. Selects the token that matches the object path.
Returns A <see cref="T:Newtonsoft.Json.Linq.JToken" /> , or <c>null</c> .
path
A <see cref="T:System.String" /> that contains a JPath expression.
public
JToken
SelectToken​(string path,
bool errorWhenNoMatch)
Inherited from JToken
Selects a <see cref="T:Newtonsoft.Json.Linq.JToken" /> using a JPath expression. Selects the token that matches the object path.
Returns A <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
path
A <see cref="T:System.String" /> that contains a JPath expression.
errorWhenNoMatch
A flag to indicate whether an error should be thrown if no tokens are found when evaluating part of the expression.
public
System.​Collections.​Generic.​IEnumerable<​JToken>
SelectTokens​(string path)
Inherited from JToken
Selects a collection of elements using a JPath expression.
Returns An <see cref="T:System.Collections.Generic.IEnumerable`1" /> of <see cref="T:Newtonsoft.Json.Linq.JToken" /> that contains the selected elements.
path
A <see cref="T:System.String" /> that contains a JPath expression.
public
System.​Collections.​Generic.​IEnumerable<​JToken>
SelectTokens​(string path,
bool errorWhenNoMatch)
Inherited from JToken
Selects a collection of elements using a JPath expression.
Returns An <see cref="T:System.Collections.Generic.IEnumerable`1" /> of <see cref="T:Newtonsoft.Json.Linq.JToken" /> that contains the selected elements.
path
A <see cref="T:System.String" /> that contains a JPath expression.
errorWhenNoMatch
A flag to indicate whether an error should be thrown if no tokens are found when evaluating part of the expression.
public
JToken
DeepClone​()
Inherited from JToken
Creates a new instance of the <see cref="T:Newtonsoft.Json.Linq.JToken" /> . All child tokens are recursively cloned.
Returns A new instance of the <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
public
void
AddAnnotation​(object annotation)
Inherited from JToken
Adds an object to the annotation list of this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
annotation
The annotation to add.
public
T
Annotation​()
Inherited from JToken
Get the first annotation object of the specified type from this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
Returns The first annotation object that matches the specified type, or <c>null</c> if no annotation is of the specified type.
public
object
Annotation​(System.​Type type)
Inherited from JToken
Gets the first annotation object of the specified type from this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
Returns The first annotation object that matches the specified type, or <c>null</c> if no annotation is of the specified type.
type
The <see cref="P:Newtonsoft.Json.Linq.JToken.Type" /> of the annotation to retrieve.
public
System.​Collections.​Generic.​IEnumerable<​T>
Annotations​()
Inherited from JToken
Gets a collection of annotations of the specified type for this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
Returns An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains the annotations for this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
public
System.​Collections.​Generic.​IEnumerable<​object>
Annotations​(System.​Type type)
Inherited from JToken
Gets a collection of annotations of the specified type for this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
Returns An <see cref="T:System.Collections.Generic.IEnumerable`1" /> of <see cref="T:System.Object" /> that contains the annotations that match the specified type for this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
type
The <see cref="P:Newtonsoft.Json.Linq.JToken.Type" /> of the annotations to retrieve.
public
void
RemoveAnnotations​()
Inherited from JToken
Removes the annotations of the specified type from this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
public
void
RemoveAnnotations​(System.​Type type)
Inherited from JToken
Removes the annotations of the specified type from this <see cref="T:Newtonsoft.Json.Linq.JToken" /> .
type
The <see cref="P:Newtonsoft.Json.Linq.JToken.Type" /> of annotations to remove.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object