Class JsonObject
- Namespace
- Nerdbank.Json
- Assembly
- Nerdbank.Json.dll
An immutable JSON object that preserves member order.
public sealed class JsonObject : JsonValue, IEquatable<JsonValue>, IReadOnlyList<KeyValuePair<string, JsonValue>>, IReadOnlyCollection<KeyValuePair<string, JsonValue>>, IEnumerable<KeyValuePair<string, JsonValue>>, IEnumerable
- Inheritance
-
JsonObject
- Implements
- Inherited Members
Constructors
JsonObject(IEnumerable<KeyValuePair<string, JsonValue>>)
Initializes a new instance of the JsonObject class.
public JsonObject(IEnumerable<KeyValuePair<string, JsonValue>> members)
Parameters
membersIEnumerable<KeyValuePair<string, JsonValue>>The ordered members. The sequence is copied. Later members win on duplicate names.
Properties
Count
Gets the number of elements in the collection.
public int Count { get; }
Property Value
- int
The number of elements in the collection.
this[int]
Gets the element at the specified index in the read-only list.
public KeyValuePair<string, JsonValue> this[int index] { get; }
Parameters
indexintThe zero-based index of the element to get.
Property Value
- KeyValuePair<string, JsonValue>
The element at the specified index in the read-only list.
this[string]
Gets the value for a member by name.
public JsonValue this[string name] { get; }
Parameters
namestringThe member name.
Property Value
- JsonValue
The value.
Exceptions
- KeyNotFoundException
Thrown if no such member exists.
Kind
Gets the kind of this value.
public override JsonValueKind Kind { get; }
Property Value
Methods
Equals(JsonValue?)
Indicates whether the current object is equal to another object of the same type.
public override bool Equals(JsonValue? other)
Parameters
otherJsonValueAn object to compare with this object.
Returns
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<KeyValuePair<string, JsonValue>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<string, JsonValue>>
An enumerator that can be used to iterate through the collection.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
TryGetValue(string, out JsonValue?)
Attempts to get a member value by name.
public bool TryGetValue(string name, out JsonValue? value)