Class JsonObject
Represents a collection of key:value pairs in a JSON structure.
Inheritance
Implements
Inherited Members
Namespace: Manatee.Json
Assembly: Manatee.Json.dll
Syntax
public class JsonObject : Dictionary<string, JsonValue>, IDictionary<string, JsonValue>, ICollection<KeyValuePair<string, JsonValue>>, IReadOnlyDictionary<string, JsonValue>, IReadOnlyCollection<KeyValuePair<string, JsonValue>>, IEnumerable<KeyValuePair<string, JsonValue>>, IDictionary, ICollection, IEnumerable, IDeserializationCallback, ISerializable
Remarks
A key is always represented as a string. A value can consist of a string, a numerical value, a boolean (true or false), a null placeholder, a JSON array of values, or a nested JSON object.
Constructors
| Improve this Doc View SourceJsonObject()
Creates an empty instance of a JSON object.
Declaration
public JsonObject()
JsonObject(IDictionary<String, Nullable<JsonValue>>)
Creates an instance of a JSON object and initializes it with the supplied JSON values.
Declaration
public JsonObject(IDictionary<string, JsonValue? > collection)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<System.String, System.Nullable<JsonValue>> | collection |
Properties
| Improve this Doc View SourceItem[String]
Gets or sets the value associated with the specified key.
Declaration
public JsonValue this[string key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key of the value to get or set. |
Property Value
Type | Description |
---|---|
JsonValue | The value associated with the specified key. |
Methods
| Improve this Doc View SourceAdd(String, Nullable<JsonValue>)
Adds the specified key and value to the dictionary.
Declaration
public void Add(string key, JsonValue? value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key of the element to add. |
System.Nullable<JsonValue> | value | The value of the element to add. If the value is null, it will be replaced by Null. |
Equals(Nullable<Object>)
Determines whether the specified System.Object is equal to the current System.Object.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Object> | obj | The System.Object to compare with the current System.Object. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified System.Object is equal to the current System.Object; otherwise, false. |
GetHashCode()
Serves as a hash function for a particular type.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code for the current System.Object. |
Overrides
GetIndentedString(Int32)
Creates a string representation of the JSON data.
Declaration
public string GetIndentedString(int indentLevel = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | indentLevel | The indention level for the object. |
Returns
Type | Description |
---|---|
System.String | A string. |
ToString()
Creates a string representation of the JSON data.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string. |
Overrides
Remarks
Passing the returned string back into the parser will result in a copy of this JSON object.