Interface JsonNode<View>

Each JsonNode represents a structural unit of a JSON document. It is like an AST node, where each node has one of the following types: "object", "array", "string", "number", "boolean", and "null".

"make" operations result into JSON nodes, for example, "make object" operation create a new "object" JSON node, "make number" operation creates a number JSON node, etc.

interface JsonNode<View> {
    api: unknown;
    id: ITimestampStruct;
    child?(): undefined | JsonNode<unknown>;
    children(callback): void;
    container(): undefined | JsonNode<unknown>;
    name(): string;
    span?(): number;
    toString(tab?): string;
    view(): View;
}

Type Parameters

  • View = unknown

Hierarchy (view full)

Implemented by

Properties

api: unknown

A singleton cache, instance which provides public API for this node.

Unique ID within a document.

Methods

  • Returns a list of immediate child nodes.

    Parameters

    • callback: ((node) => void)
        • (node): void
        • Parameters

          Returns void

    Returns void

  • Returns itself if the node is a container node. Or asks its child (if any) to return a container node. A container node is one that holds other multiple other nodes which can be addressed. For example, an object and an array are container nodes, as they hold other nodes.

    Returns undefined | JsonNode<unknown>

  • Sometimes an Identifiable can be a compound entity, which holds multiple entries with sequentially growing timestamps. In this case span represents the number of entries.

    Returns number

  • Parameters

    • Optional tab: string

    Returns string