Class JObject
Represents a JSON object.
Implements
Inherited Members
Namespace: Bayat.Json.Linq
Assembly: Bayat.Json.Runtime.dll
Syntax
public class JObject : JContainer, IJEnumerable<JToken>, IJsonLineInfo, ICloneable, IDynamicMetaObjectProvider, IList<JToken>, ICollection<JToken>, IEnumerable<JToken>, ITypedList, IBindingList, IList, ICollection, INotifyCollectionChanged, IDictionary<string, JToken>, ICollection<KeyValuePair<string, JToken>>, IEnumerable<KeyValuePair<string, JToken>>, IEnumerable, INotifyPropertyChanged, ICustomTypeDescriptor, INotifyPropertyChanging
Examples
Constructors
| Improve this Doc View SourceJObject()
Initializes a new instance of the JObject class.
Declaration
public JObject()
JObject(JObject)
Declaration
public JObject(JObject other)
Parameters
| Improve this Doc View SourceJObject(Object)
Initializes a new instance of the JObject class with the specified content.
Declaration
public JObject(object content)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
content | The contents of the object. |
JObject(Object[])
Initializes a new instance of the JObject class with the specified content.
Declaration
public JObject(params object[] content)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
content | The contents of the object. |
Properties
| Improve this Doc View SourceChildrenTokens
Gets the container's children tokens.
Declaration
protected override IList<JToken> ChildrenTokens { get; }
Property Value
| Type | Description |
|---|---|
| System. |
The container's children tokens. |
Overrides
| Improve this Doc View SourceItem[Object]
Gets the JToken with the specified key.
Declaration
public override JToken this[object key] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
key |
Property Value
Overrides
| Improve this Doc View SourceItem[String]
Gets or sets the JToken with the specified property name.
Declaration
public JToken this[string propertyName] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
propertyName |
Property Value
| Type | Description |
|---|---|
| JToken |
Type
Gets the node type for this JToken.
Declaration
public override JTokenType Type { get; }
Property Value
| Type | Description |
|---|---|
| JToken |
The type. |
Overrides
Methods
| Improve this Doc View SourceAdd(String, JToken)
Adds the specified property name.
Declaration
public void Add(string propertyName, JToken value)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
propertyName | Name of the property. |
| JToken | value | The value. |
CloneToken()
Declaration
public override JToken CloneToken()
Returns
| Type | Description |
|---|---|
| JToken |
Overrides
| Improve this Doc View SourceDeepEquals(JToken)
Declaration
public override bool DeepEquals(JToken node)
Parameters
| Type | Name | Description |
|---|---|---|
| JToken | node |
Returns
| Type | Description |
|---|---|
| System. |
Overrides
| Improve this Doc View SourceFromObject(Object)
Creates a JObject from an object.
Declaration
public static JObject FromObject(object o)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
o | The object that will be used to create JObject. |
Returns
| Improve this Doc View SourceFromObject(Object, JsonSerializer)
Creates a JObject from an object.
Declaration
public static JObject FromObject(object o, JsonSerializer jsonSerializer)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
o | The object that will be used to create JObject. |
| Json |
jsonSerializer | The Json |
Returns
| Improve this Doc View SourceGetDeepHashCode()
Declaration
public override int GetDeepHashCode()
Returns
| Type | Description |
|---|---|
| System. |
Overrides
| Improve this Doc View SourceGetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<KeyValuePair<string, JToken>> GetEnumerator()
Returns
| Type | Description |
|---|---|
| System. |
A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the collection. |
GetMetaObject(Expression)
Returns the System.
Declaration
protected override DynamicMetaObject GetMetaObject(Expression parameter)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
parameter | The expression tree representation of the runtime value. |
Returns
| Type | Description |
|---|---|
| System. |
The System. |
Overrides
| Improve this Doc View SourceGetValue(String)
Gets the JToken with the specified property name.
Declaration
public JToken GetValue(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
propertyName | Name of the property. |
Returns
| Improve this Doc View SourceGetValue(String, StringComparison)
Gets the JToken with the specified property name.
The exact property name will be searched for first and if no matching property is found then
the System.
Declaration
public JToken GetValue(string propertyName, StringComparison comparison)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
propertyName | Name of the property. |
| System. |
comparison | One of the enumeration values that specifies how the strings will be compared. |
Returns
| Improve this Doc View SourceIndexOfItem(JToken)
Declaration
public override int IndexOfItem(JToken item)
Parameters
| Type | Name | Description |
|---|---|---|
| JToken | item |
Returns
| Type | Description |
|---|---|
| System. |
Overrides
| Improve this Doc View SourceInsertItem(Int32, JToken, Boolean)
Declaration
public override void InsertItem(int index, JToken item, bool skipParentCheck)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
index | |
| JToken | item | |
| System. |
skipParentCheck |
Overrides
| Improve this Doc View SourceLoad(JsonReader)
Loads an JObject from a Json
Declaration
public static JObject Load(JsonReader reader)
Parameters
| Type | Name | Description |
|---|---|---|
| Json |
reader | A Json |
Returns
| Type | Description |
|---|---|
| JObject | A JObject that contains the JSON that was read from the specified Json |
Load(JsonReader, JsonLoadSettings)
Loads an JObject from a Json
Declaration
public static JObject Load(JsonReader reader, JsonLoadSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| Json |
reader | A Json |
| Json |
settings | The Json |
Returns
| Type | Description |
|---|---|
| JObject | A JObject that contains the JSON that was read from the specified Json |
MergeItem(Object, JsonMergeSettings)
Declaration
public override void MergeItem(object content, JsonMergeSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
content | |
| Json |
settings |
Overrides
| Improve this Doc View SourceOnPropertyChanged(String)
Raises the Property
Declaration
protected virtual void OnPropertyChanged(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
propertyName | Name of the property. |
OnPropertyChanging(String)
Raises the Property
Declaration
protected virtual void OnPropertyChanging(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
propertyName | Name of the property. |
Parse(String)
Load a JObject from a string that contains JSON.
Declaration
public static JObject Parse(string json)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
json | A System. |
Returns
Examples
|
Improve this Doc
View Source
Parse(String, JsonLoadSettings)
Load a JObject from a string that contains JSON.
Declaration
public static JObject Parse(string json, JsonLoadSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
json | A System. |
| Json |
settings | The Json |
Returns
Examples
|
Improve this Doc
View Source
Properties()
Gets an System.Collections.Generic.IEnumerable<T> of this object's properties.
Declaration
public IEnumerable<JProperty> Properties()
Returns
| Type | Description |
|---|---|
| System. |
An System.Collections.Generic.IEnumerable<T> of this object's properties. |
Property(String)
Gets a JProperty the specified name.
Declaration
public JProperty Property(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
name | The property name. |
Returns
| Improve this Doc View SourcePropertyValues()
Gets an JEnumerable<T> of this object's property values.
Declaration
public JEnumerable<JToken> PropertyValues()
Returns
| Type | Description |
|---|---|
| JEnumerable<JToken> | An JEnumerable<T> of this object's property values. |
Remove(String)
Removes the property with the specified name.
Declaration
public bool Remove(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
propertyName | Name of the property. |
Returns
| Type | Description |
|---|---|
| System. |
true if item was successfully removed; otherwise, false. |
TryGetValue(String, out JToken)
Tries the get value.
Declaration
public bool TryGetValue(string propertyName, out JToken value)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
propertyName | Name of the property. |
| JToken | value | The value. |
Returns
| Type | Description |
|---|---|
| System. |
true if a value was successfully retrieved; otherwise, false. |
TryGetValue(String, StringComparison, out JToken)
Tries to get the JToken with the specified property name.
The exact property name will be searched for first and if no matching property is found then
the System.
Declaration
public bool TryGetValue(string propertyName, StringComparison comparison, out JToken value)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
propertyName | Name of the property. |
| System. |
comparison | One of the enumeration values that specifies how the strings will be compared. |
| JToken | value | The value. |
Returns
| Type | Description |
|---|---|
| System. |
true if a value was successfully retrieved; otherwise, false. |
ValidateToken(JToken, JToken)
Declaration
public override void ValidateToken(JToken o, JToken existing)
Parameters
Overrides
| Improve this Doc View SourceWriteTo(JsonWriter, JsonConverter[])
Writes this token to a Json
Declaration
public override void WriteTo(JsonWriter writer, params JsonConverter[] converters)
Parameters
| Type | Name | Description |
|---|---|---|
| Json |
writer | A Json |
| Json |
converters | A collection of Json |
Overrides
Events
| Improve this Doc View SourcePropertyChanged
Occurs when a property value changes.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
| Type | Description |
|---|---|
| System. |
PropertyChanging
Occurs when a property value is changing.
Declaration
public event PropertyChangingEventHandler PropertyChanging
Event Type
| Type | Description |
|---|---|
| System. |
Explicit Interface Implementations
| Improve this Doc View SourceICollection<KeyValuePair<String, JToken>>.Add(KeyValuePair<String, JToken>)
Declaration
void ICollection<KeyValuePair<string, JToken>>.Add(KeyValuePair<string, JToken> item)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
item |
ICollection<KeyValuePair<String, JToken>>.Clear()
Declaration
void ICollection<KeyValuePair<string, JToken>>.Clear()
ICollection<KeyValuePair<String, JToken>>.Contains(KeyValuePair<String, JToken>)
Declaration
bool ICollection<KeyValuePair<string, JToken>>.Contains(KeyValuePair<string, JToken> item)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
item |
Returns
| Type | Description |
|---|---|
| System. |
ICollection<KeyValuePair<String, JToken>>.CopyTo(KeyValuePair<String, JToken>[], Int32)
Declaration
void ICollection<KeyValuePair<string, JToken>>.CopyTo(KeyValuePair<string, JToken>[] array, int arrayIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
array | |
| System. |
arrayIndex |
ICollection<KeyValuePair<String, JToken>>.IsReadOnly
Declaration
bool ICollection<KeyValuePair<string, JToken>>.IsReadOnly { get; }
Returns
| Type | Description |
|---|---|
| System. |
ICollection<KeyValuePair<String, JToken>>.Remove(KeyValuePair<String, JToken>)
Declaration
bool ICollection<KeyValuePair<string, JToken>>.Remove(KeyValuePair<string, JToken> item)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
item |
Returns
| Type | Description |
|---|---|
| System. |
IDictionary<String, JToken>.ContainsKey(String)
Declaration
bool IDictionary<string, JToken>.ContainsKey(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
key |
Returns
| Type | Description |
|---|---|
| System. |
IDictionary<String, JToken>.Keys
Declaration
ICollection<string> IDictionary<string, JToken>.Keys { get; }
Returns
| Type | Description |
|---|---|
| System. |
IDictionary<String, JToken>.Values
Declaration
ICollection<JToken> IDictionary<string, JToken>.Values { get; }
Returns
| Type | Description |
|---|---|
| System. |
ICustomTypeDescriptor.GetAttributes()
Returns a collection of custom attributes for this instance of a component.
Declaration
AttributeCollection ICustomTypeDescriptor.GetAttributes()
Returns
| Type | Description |
|---|---|
| System. |
An System. |
ICustomTypeDescriptor.GetClassName()
Returns the class name of this instance of a component.
Declaration
string ICustomTypeDescriptor.GetClassName()
Returns
| Type | Description |
|---|---|
| System. |
The class name of the object, or null if the class does not have a name. |
ICustomTypeDescriptor.GetComponentName()
Returns the name of this instance of a component.
Declaration
string ICustomTypeDescriptor.GetComponentName()
Returns
| Type | Description |
|---|---|
| System. |
The name of the object, or null if the object does not have a name. |
ICustomTypeDescriptor.GetConverter()
Returns a type converter for this instance of a component.
Declaration
TypeConverter ICustomTypeDescriptor.GetConverter()
Returns
| Type | Description |
|---|---|
| System. |
A System. |
ICustomTypeDescriptor.GetDefaultEvent()
Returns the default event for this instance of a component.
Declaration
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent()
Returns
| Type | Description |
|---|---|
| System. |
An System. |
ICustomTypeDescriptor.GetDefaultProperty()
Returns the default property for this instance of a component.
Declaration
PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty()
Returns
| Type | Description |
|---|---|
| System. |
A System. |
ICustomTypeDescriptor.GetEditor(Type)
Returns an editor of the specified type for this instance of a component.
Declaration
object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
editorBaseType | A System. |
Returns
| Type | Description |
|---|---|
| System. |
An System. |
ICustomTypeDescriptor.GetEvents()
Returns the events for this instance of a component.
Declaration
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
Returns
| Type | Description |
|---|---|
| System. |
An System. |
ICustomTypeDescriptor.GetEvents(Attribute[])
Returns the events for this instance of a component using the specified attribute array as a filter.
Declaration
EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
attributes | An array of type System. |
Returns
| Type | Description |
|---|---|
| System. |
An System. |
ICustomTypeDescriptor.GetProperties()
Returns the properties for this instance of a component.
Declaration
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
Returns
| Type | Description |
|---|---|
| System. |
A System. |
ICustomTypeDescriptor.GetProperties(Attribute[])
Returns the properties for this instance of a component using the attribute array as a filter.
Declaration
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
attributes | An array of type System. |
Returns
| Type | Description |
|---|---|
| System. |
A System. |
ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor)
Returns an object that contains the property described by the specified property descriptor.
Declaration
object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
pd | A System. |
Returns
| Type | Description |
|---|---|
| System. |
An System. |