Class JObject
- Namespace
- Newtonsoft.Json.Linq
- Assembly
- Newtonsoft.Json.dll
Represents a JSON object.
public class JObject : JContainer, IJEnumerable<JToken>, IJsonLineInfo, ICloneable, IList<JToken>, ICollection<JToken>, IEnumerable<JToken>, ITypedList, IBindingList, IList, ICollection, IDictionary<string, JToken>, ICollection<KeyValuePair<string, JToken>>, IEnumerable<KeyValuePair<string, JToken>>, IEnumerable, INotifyPropertyChanged, ICustomTypeDescriptor, INotifyPropertyChanging
- Inheritance
-
JObject
- Implements
- Inherited Members
- Extension Methods
Constructors
JObject()
Initializes a new instance of the JObject class.
public JObject()
JObject(JObject)
public JObject(JObject other)
Parameters
JObject(object)
Initializes a new instance of the JObject class with the specified content.
public JObject(object content)
Parameters
content
objectThe contents of the object.
JObject(params object[])
Initializes a new instance of the JObject class with the specified content.
public JObject(params object[] content)
Parameters
content
object[]The contents of the object.
Properties
ChildrenTokens
Gets the container's children tokens.
protected override IList<JToken> ChildrenTokens { get; }
Property Value
this[object]
Gets the JToken with the specified key.
public override JToken this[object key] { get; set; }
Parameters
key
object
Property Value
this[string]
Gets or sets the JToken with the specified property name.
public JToken this[string propertyName] { get; set; }
Parameters
propertyName
string
Property Value
Type
Gets the node type for this JToken.
public override JTokenType Type { get; }
Property Value
- JTokenType
The type.
Methods
Add(string, JToken)
Adds the specified property name.
public void Add(string propertyName, JToken value)
Parameters
FromObject(object)
Creates a JObject from an object.
public static JObject FromObject(object o)
Parameters
Returns
FromObject(object, JsonSerializer)
Creates a JArray from an object.
public static JObject FromObject(object o, JsonSerializer jsonSerializer)
Parameters
o
objectThe object that will be used to create JArray.
jsonSerializer
JsonSerializerThe JsonSerializer that will be used to read the object.
Returns
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<KeyValuePair<string, JToken>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<string, JToken>>
A IEnumerator<T> that can be used to iterate through the collection.
Load(JsonReader)
Loads an JObject from a JsonReader.
public static JObject Load(JsonReader reader)
Parameters
reader
JsonReaderA JsonReader that will be read for the content of the JObject.
Returns
- JObject
A JObject that contains the JSON that was read from the specified JsonReader.
OnPropertyChanged(string)
Raises the PropertyChanged event with the provided arguments.
protected virtual void OnPropertyChanged(string propertyName)
Parameters
propertyName
stringName of the property.
OnPropertyChanging(string)
Raises the PropertyChanging event with the provided arguments.
protected virtual void OnPropertyChanging(string propertyName)
Parameters
propertyName
stringName of the property.
Parse(string)
Load a JObject from a string that contains JSON.
public static JObject Parse(string json)
Parameters
Returns
Properties()
Gets an IEnumerable<T> of this object's properties.
public IEnumerable<JProperty> Properties()
Returns
- IEnumerable<JProperty>
An IEnumerable<T> of this object's properties.
Property(string)
Gets a JProperty the specified name.
public JProperty Property(string name)
Parameters
name
stringThe property name.
Returns
PropertyValues()
Gets an JEnumerable<T> of this object's property values.
public JEnumerable<JToken> PropertyValues()
Returns
- JEnumerable<JToken>
An JEnumerable<T> of this object's property values.
Remove(string)
Removes the property with the specified name.
public bool Remove(string propertyName)
Parameters
propertyName
stringName of the property.
Returns
- bool
true if item was successfully removed; otherwise, false.
TryGetValue(string, out JToken)
Tries the get value.
public bool TryGetValue(string propertyName, out JToken value)
Parameters
Returns
- bool
true if a value was successfully retrieved; otherwise, false.
WriteTo(JsonWriter, params JsonConverter[])
Writes this token to a JsonWriter.
public override void WriteTo(JsonWriter writer, params JsonConverter[] converters)
Parameters
writer
JsonWriterA JsonWriter into which this method will write.
converters
JsonConverter[]A collection of JsonConverter which will be used when writing the token.
Events
PropertyChanged
Occurs when a property value changes.
public event PropertyChangedEventHandler PropertyChanged
Event Type
PropertyChanging
Occurs when a property value is changing.
public event PropertyChangingEventHandler PropertyChanging