Table of Contents

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)

Initializes a new instance of the JObject class from another JObject object.

public JObject(JObject other)

Parameters

other JObject

A JObject object to copy from.

JObject(object)

Initializes a new instance of the JObject class with the specified content.

public JObject(object content)

Parameters

content object

The 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

IList<JToken>

The container's children tokens.

this[object]

Gets the JToken with the specified key.

public override JToken this[object key] { get; set; }

Parameters

key object

Property Value

JToken

The JToken with the specified key.

this[string]

Gets or sets the JToken with the specified property name.

public JToken this[string propertyName] { get; set; }

Parameters

propertyName string

Property Value

JToken

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

propertyName string

Name of the property.

value JToken

The value.

FromObject(object)

Creates a JObject from an object.

public static JObject FromObject(object o)

Parameters

o object

The object that will be used to create JObject.

Returns

JObject

A JObject with the values of the specified object

FromObject(object, JsonSerializer)

Creates a JArray from an object.

public static JObject FromObject(object o, JsonSerializer jsonSerializer)

Parameters

o object

The object that will be used to create JArray.

jsonSerializer JsonSerializer

The JsonSerializer that will be used to read the object.

Returns

JObject

A JArray with the values of the specified object

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 JsonReader

A 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 string

Name of the property.

OnPropertyChanging(string)

Raises the PropertyChanging event with the provided arguments.

protected virtual void OnPropertyChanging(string propertyName)

Parameters

propertyName string

Name of the property.

Parse(string)

Load a JObject from a string that contains JSON.

public static JObject Parse(string json)

Parameters

json string

A string that contains JSON.

Returns

JObject

A JObject populated from the string that contains JSON.

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 string

The property name.

Returns

JProperty

A JProperty with the specified name or null.

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 string

Name 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

propertyName string

Name of the property.

value JToken

The value.

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 JsonWriter

A 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

PropertyChangedEventHandler

PropertyChanging

Occurs when a property value is changing.

public event PropertyChangingEventHandler PropertyChanging

Event Type

PropertyChangingEventHandler