Class JsonObject
Represents the json object.
Inheritance
Namespace:Dapplo.HttpExtensions
Assembly:Dapplo.HttpExtensions.dll
Syntax
public class JsonObject : DynamicObject, IDynamicMetaObjectProvider, IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable
Constructors
| Improve this Doc View SourceJsonObject()
Initializes a new instance of JsonObject.
Declaration
public JsonObject()
JsonObject(IEqualityComparer<String>)
Initializes a new instance of JsonObject.
Declaration
public JsonObject(IEqualityComparer<string> comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEqualityComparer<System.String> | comparer | The System.Collections.Generic.IEqualityComparer`1 implementation to use when comparing keys, or null to use the default System.Collections.Generic.EqualityComparer`1 for the type of the key. |
Properties
| Improve this Doc View SourceCount
Gets the count.
Declaration
public int Count { get; }
Returns
Type | Description |
---|---|
System.Int32 |
IsReadOnly
Gets a value indicating whether this instance is read only.
Declaration
public bool IsReadOnly { get; }
Returns
Type | Description |
---|---|
System.Boolean |
Item[Int32]
Gets the System.Object at the specified index.
Declaration
public object this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Returns
Type | Description |
---|---|
System.Object |
Item[String]
Gets or sets the System.Object with the specified key.
Declaration
public object this[string key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | key |
Returns
Type | Description |
---|---|
System.Object |
Keys
Gets the keys.
Declaration
public ICollection<string> Keys { get; }
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.String> |
Values
Gets the values.
Declaration
public ICollection<object> Values { get; }
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.Object> |
Methods
| Improve this Doc View SourceAdd(KeyValuePair<String, Object>)
Adds the specified item.
Declaration
public void Add(KeyValuePair<string, object> item)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<System.String, System.Object> | item | The item. |
Add(String, Object)
Adds the specified key.
Declaration
public void Add(string key, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
System.Object | value | The value. |
Clear()
Clears this instance.
Declaration
public void Clear()
Contains(KeyValuePair<String, Object>)
Determines whether [contains] [the specified item].
Declaration
public bool Contains(KeyValuePair<string, object> item)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<System.String, System.Object> | item | The item. |
Returns
Type | Description |
---|---|
System.Boolean |
|
ContainsKey(String)
Determines whether the specified key contains key.
Declaration
public bool ContainsKey(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
Returns
Type | Description |
---|---|
System.Boolean |
|
CopyTo(KeyValuePair<String, Object>[], Int32)
Copies to.
Declaration
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<System.String, System.Object>[] | array | The array. |
System.Int32 | arrayIndex | Index of the array. |
GetDynamicMemberNames()
Returns the enumeration of all dynamic member names.
Declaration
public override IEnumerable<string> GetDynamicMemberNames()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A sequence that contains dynamic member names. |
GetEnumerator()
Gets the enumerator.
Declaration
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.String, System.Object>> |
Remove(KeyValuePair<String, Object>)
Removes the specified item.
Declaration
public bool Remove(KeyValuePair<string, object> item)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<System.String, System.Object> | item | The item. |
Returns
Type | Description |
---|---|
System.Boolean |
Remove(String)
Removes the specified key.
Declaration
public bool Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
Returns
Type | Description |
---|---|
System.Boolean |
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | An System.Collections.IEnumerator object that can be used to iterate through the collection. |
ToString()
Returns a json System.String that represents the current System.Object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A json System.String that represents the current System.Object. |
TryConvert(ConvertBinder, out Object)
Provides implementation for type conversion operations. Classes derived from the System.Dynamic.DynamicObject class can override this method to specify dynamic behavior for operations that convert an object from one type to another.
Declaration
public override bool TryConvert(ConvertBinder binder, out object result)
Parameters
Type | Name | Description |
---|---|---|
System.Dynamic.ConvertBinder | binder | Provides information about the conversion operation. The binder.Type property provides the type to which the object must be converted. For example, for the statement (String)sampleObject in C# (CType(sampleObject, Type) in Visual Basic), where sampleObject is an instance of the class derived from the System.Dynamic.DynamicObject class, binder.Type returns the System.String type. The binder.Explicit property provides information about the kind of conversion that occurs. It returns true for explicit conversion and false for implicit conversion. |
System.Object | result | The result of the type conversion operation. |
Returns
Type | Description |
---|---|
System.Boolean | Alwasy returns true. |
TryDeleteMember(DeleteMemberBinder)
Provides the implementation for operations that delete an object member. This method is not intended for use in C# or Visual Basic.
Declaration
public override bool TryDeleteMember(DeleteMemberBinder binder)
Parameters
Type | Name | Description |
---|---|---|
System.Dynamic.DeleteMemberBinder | binder | Provides information about the deletion. |
Returns
Type | Description |
---|---|
System.Boolean | Alwasy returns true. |
TryGetIndex(GetIndexBinder, Object[], out Object)
Provides the implementation for operations that get a value by index. Classes derived from the System.Dynamic.DynamicObject class can override this method to specify dynamic behavior for indexing operations.
Declaration
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
Parameters
Type | Name | Description |
---|---|---|
System.Dynamic.GetIndexBinder | binder | Provides information about the operation. |
System.Object[] | indexes | The indexes that are used in the operation. For example, for the sampleObject[3] operation in C# (sampleObject(3) in Visual Basic), where sampleObject is derived from the DynamicObject class, indexes is equal to 3. |
System.Object | result | The result of the index operation. |
Returns
Type | Description |
---|---|
System.Boolean | Alwasy returns true. |
TryGetMember(GetMemberBinder, out Object)
Provides the implementation for operations that get member values. Classes derived from the System.Dynamic.DynamicObject class can override this method to specify dynamic behavior for operations such as getting a value for a property.
Declaration
public override bool TryGetMember(GetMemberBinder binder, out object result)
Parameters
Type | Name | Description |
---|---|---|
System.Dynamic.GetMemberBinder | binder | Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the System.Dynamic.DynamicObject class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive. |
System.Object | result | The result of the get operation. For example, if the method is called for a property, you can assign the property value to result. |
Returns
Type | Description |
---|---|
System.Boolean | Alwasy returns true. |
TryGetValue(String, out Object)
Tries the get value.
Declaration
public bool TryGetValue(string key, out object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
System.Object | value | The value. |
Returns
Type | Description |
---|---|
System.Boolean |
TrySetIndex(SetIndexBinder, Object[], Object)
Provides the implementation for operations that set a value by index. Classes derived from the System.Dynamic.DynamicObject class can override this method to specify dynamic behavior for operations that access objects by a specified index.
Declaration
public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Dynamic.SetIndexBinder | binder | Provides information about the operation. |
System.Object[] | indexes | The indexes that are used in the operation. For example, for the sampleObject[3] = 10 operation in C# (sampleObject(3) = 10 in Visual Basic), where sampleObject is derived from the System.Dynamic.DynamicObject class, indexes is equal to 3. |
System.Object | value | The value to set to the object that has the specified index. For example, for the sampleObject[3] = 10 operation in C# (sampleObject(3) = 10 in Visual Basic), where sampleObject is derived from the System.Dynamic.DynamicObject class, value is equal to 10. |
Returns
Type | Description |
---|---|
System.Boolean | true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown. |
TrySetMember(SetMemberBinder, Object)
Provides the implementation for operations that set member values. Classes derived from the System.Dynamic.DynamicObject class can override this method to specify dynamic behavior for operations such as setting a value for a property.
Declaration
public override bool TrySetMember(SetMemberBinder binder, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Dynamic.SetMemberBinder | binder | Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member to which the value is being assigned. For example, for the statement sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the System.Dynamic.DynamicObject class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive. |
System.Object | value | The value to set to the member. For example, for sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the System.Dynamic.DynamicObject class, the value is "Test". |
Returns
Type | Description |
---|---|
System.Boolean | true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.) |