JsonWritableProxyDictionary<TValue>

Namespace: SnowBank.Data.Json · struct

Implements: IDictionary<string, TValue>, ICollection<KeyValuePair<string, TValue>>, IEnumerable<KeyValuePair<string, TValue>>, IEnumerable, IJsonProxyNode, IJsonSerializable, IJsonPackable

Wraps a JsonObject into a typed mutable proxy that emulates a dictionary of elements of type TValue

Constructors

JsonWritableProxyDictionary<TValue>

JsonWritableProxyDictionary<TValue>(MutableJsonValue value, IJsonConverter<TValue> converter = null, IJsonProxyNode parent = null, JsonPathSegment segment = null)

Properties

Count

int Count { get; }

Item

TValue Item { get; set; }

TValue Item { get; set; }

TValue Item { get; }

Keys

ICollection<string> Keys { get; }

Values

ICollection<TValue> Values { get; }

Methods

Add

void Add(string key, TValue value)

void Add(ReadOnlyMemory<char> key, TValue value)

Clear

void Clear()

ContainsKey

bool ContainsKey(string key)

bool ContainsKey(ReadOnlyMemory<char> key)

bool ContainsKey(ReadOnlySpan<char> key)

CopyTo

void CopyTo(KeyValuePair<string, TValue>[] array, int arrayIndex)

Exists

bool Exists()

Tests if the object is present.

Returns: false if the wrapped JSON value is null or empty; otherwise, true.

GetEnumerator

IEnumerator<KeyValuePair<string, TValue>> GetEnumerator()

GetPath

JsonPath GetPath()

Returns the path to this node, from the root

JsonPath GetPath(JsonPathSegment child)

Returns the path to a child of this value, from the root

IsNullOrEmpty

bool IsNullOrEmpty()

Tests if the object is null, missing, or empty.

Returns: true if the wrapped JSON value is null, missing or an empty object; otherwise, false.

This can return false if the wrapped value is an empty object, or another type, like an array, string literal, etc...

IsNullOrMissing

bool IsNullOrMissing()

Tests if the object is null or missing.

Returns: true if the wrapped JSON value is null or missing; otherwise, false.

This can return false if the wrapped value is another type, like an array, string literal, etc...

IsObject

bool IsObject()

Tests if the wrapped value is a valid JSON Object.

Returns: true if the wrapped JSON value is a non-null Object; otherwise, false

This can be used to protect against malformed JSON document that would have a different type (array, string literal, ...).

IsObjectOrMissing

bool IsObjectOrMissing()

Tests if the wrapped value is a valid JSON Object, or is null-or-missing.

Returns: true if the wrapped JSON value either null-or-missing, or an Object; otherwise, false

This can be used to protect against malformed JSON document that would have a different type (array, string literal, ...).

Remove

bool Remove(KeyValuePair<string, TValue> item)

bool Remove(string key)

bool Remove(ReadOnlyMemory<char> key)

Set

void Set(string key, TValue value)

void Set(ReadOnlyMemory<char> key, TValue value)

ToDictionary

Dictionary<string, TValue> ToDictionary(IEqualityComparer<string> keyComparer = null)

ToJsonValue

JsonValue ToJsonValue()

ToString

string ToString()

TryGetValue

bool TryGetValue(string key, out TValue value)

bool TryGetValue(ReadOnlyMemory<char> key, out TValue value)

bool TryGetValue(ReadOnlySpan<char> key, out TValue value)