JsonNode Class

Class used to construct a document object model (DOM) that represents a JSON document or fragment.

Definition

Namespace: MichaelBrooks.UK.Json
Assembly: JsonDOM (in JsonDOM.dll) Version: 1.0.7
C#
public class JsonNode
Inheritance
Object    JsonNode

Remarks

Constructors

Properties

Children Returns a list of members (if this node represents an object) or elements (if it represents an array), or is null if this node represents a simple type. Note that it is expected that you will normally find it easier to retrieve individual member nodes via the ItemString property when dealing with an object, and the ItemInt32 property when dealing with an array.
ItemInt32 Alternative to using the Children collection when the node is of type Array, that gets a child node keyed on its array index.
ItemString Alternative to using the Children collection when the node is of type Object, that gets a child node keyed on its name. If duplicate named siblings exist, reacts as per the unexpectedDuplicateSiblingReaction parameter of the current object's constructor. If no child with the specified name exists, throws a JsonNodeMemberNotFoundException. If the node is not of type Object, throws an InvalidOperationException.
JsonName The node name will only be set when the node represents a child member of an object node. This is the name as it would appear in a JSON document, but without the surrounding quotation marks.
JsonValue 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.
JsonValueType Get or Set the JSON type of the value. Once this has been set to anything other than Uninitialised or Null, it cannot be set again. The exceptions to this rule are that True can be changed to False and vice versa, and anything can be set to Null at any time. Setting from Null to Array or Object will result in Children being initialised to an empty node list.
Parent Null when this node represents the top level (root) of the JSON document.

Methods

EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Serialise(JsonFormat) Serialise into the specified layout. If Indent_Spaces is selected, a default of four spaces per indent level will be used.
Serialise(UInt32) Serialise to a multiline layout, indented using spaces and a specified indent size.
ToStringReturns a string that represents the current object.
(Inherited from Object)

Thread Safety

There are no thread-safe members of this class.

See Also