JsonWritableProxyObjectBase
Namespace: SnowBank.Data.Json · class
Implements: IJsonWritableProxy, IJsonSerializable, IJsonPackable, IJsonProxyNode, IEquatable<JsonValue>, IEquatable<MutableJsonValue>, IEquatable<JsonWritableProxyObjectBase>
Base class for custom or source generated implementations of a IJsonWritableProxy
Remarks
This contains all the boilerplate implementation that is common to most custom implementations
Properties
Item
MutableJsonValue Item { get; }
MutableJsonValue Item { get; }
Methods
<Clone>$
JsonWritableProxyObjectBase <Clone>$()
Equals
bool Equals(JsonValue value)
bool Equals(MutableJsonValue value)
bool Equals(object obj)
bool Equals(JsonWritableProxyObjectBase other)
Exists
bool Exists()
Tests if the object is present.
Returns: false if the wrapped JSON value is null or empty; otherwise, true.
Get
MutableJsonValue Get()
Returns the underlying mutable value
This value can be used to "escape" the type safety of the proxy, while still allowing for tracking of mutations.
MutableJsonValue Get(string name)
Returns the value of the field with the specified name
name— Name of the field
This value can be used to "escape" the type safety of the proxy, while still allowing for tracking of mutations.
MutableJsonValue Get(ReadOnlyMemory<char> name)
Returns the value of the field with the specified name
name— Name of the field
This value can be used to "escape" the type safety of the proxy, while still allowing for tracking of mutations.
GetContext
IMutableJsonContext GetContext()
Returns the (optional) tracking context attached to this instance
If non-null, this context will record all changed made to this instance, or any of its children
GetHashCode
int GetHashCode()
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, ...).
JsonPack
JsonValue JsonPack(CrystalJsonSettings settings, ICrystalJsonTypeResolver resolver)
Converts an instance of this type into the equivalent JSON value, usually a JSON Object or Array
settings— Serialization settingsresolver— Custom resolver used to bind the value into a managed type.
If the type also implements , the result of parsing the resulting JSON value should produce an object that is equivalent to the original (or as close as possible if some values loose some precision after serialization)
JsonSerialize
void JsonSerialize(CrystalJsonWriter writer)
Serializes this instance as JSON
writer— Writer that will output the content of this instance
Set
void Set(MutableJsonValue value)
Changes the value of this object
value— New value that replaces the content of this object
void Set(JsonValue value)
Changes the value of this object
value— New value that replaces the content of this object
void Set(string name, JsonValue value)
Sets or changes the value of the field with the given name
name— Name of the fieldvalue— New value that replaces the content of this object
void Set(ReadOnlyMemory<char> name, JsonValue value)
Sets or changes the value of the field with the given name
name— Name of the fieldvalue— New value that replaces the content of this object
void Set(string name, MutableJsonValue value)
Sets or changes the value of the field with the given name
name— Name of the fieldvalue— New value that replaces the content of this object
void Set(ReadOnlyMemory<char> name, MutableJsonValue value)
Sets or changes the value of the field with the given name
name— Name of the fieldvalue— New value that replaces the content of this object
ToJsonValue
JsonValue ToJsonValue()
Returns the proxied JSON Value
The returned value may not be mutable and should only not be changed directly.
Any mutations made to this value will not be captured by the attached context!
ToString
string ToString()