JsonWritableProxyDictionary<TValue, TProxy>

Namespace: SnowBank.Data.Json · struct

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

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

Constructors

JsonWritableProxyDictionary<TValue, TProxy>

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

Properties

Count

int Count { get; }

Item

TProxy Item { get; set; }

TProxy Item { get; set; }

Keys

ICollection<string> Keys { get; }

Type

JsonType Type { get; }

Type of JSON value wrapped by this node

Values

ICollection<TProxy> Values { get; }

Methods

Add

void Add(string key, TProxy value)

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

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)

CopyTo

void CopyTo(KeyValuePair<string, TProxy>[] 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, TProxy>> 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(string key)

bool Remove(ReadOnlyMemory<char> key)

Set

void Set(string key, TProxy value)

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

void Set(string key, TValue value)

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

ToDictionary

Dictionary<string, TValue> ToDictionary()

ToJsonValue

JsonValue ToJsonValue()

ToString

string ToString()

TryGetValue

bool TryGetValue(string key, out TProxy value)

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