JsonNodeJsonValue Property

Get or Set the JSON value for non-complex types (i.e. non-array and non-object). When setting, the value must be compatible with the JsonValueType that has already been set. Get will return a string (minus the quotation marks that delimit it in the raw JSON) when JsonValueType is String. Get will return "null", "true", or "false" (again without the quotation marks) when JsonValueType is Null, True, or False respectively. Get will return null when JsonValueType is Array or Object (see Remarks). Get will throw an InvalidOperationException when JsonValueType is Uninitialised. If you try setting to "null", "true", or "false", how that is dealt with will depend upon what JsonValueType has been set to. The only way to manipulate the value of a complex (i.e. object or array) type is to work with its Children collection.

Definition

Namespace: MichaelBrooks.UK.Json
Assembly: JsonDOM (in JsonDOM.dll) Version: 1.0.7
C#
public string? JsonValue { get; set; }

Property Value

String

Remarks

Returning null on a Get when it's a complex type allows callers to safely concatenate the result with other strings regardless of what type of data is held, while throwing when uninitialised protects against callers attempting to do so when they shouldn't.
Online page.

Exceptions

InvalidOperationExceptionThrown on Get when JsonValueType is Uninitialised, on Set before JsonValueType has been set, or on Set when JsonValueType is Array or Object.
InvalidCastExceptionThrown when attempting to set a value that is not valid for the current JsonValueType.

See Also