json-stream-lite - v1.0.17
    Preparing search index...

    Class JsonValue<T, K>

    Represents any JSON value (primitive, object, or array). Provides lazy evaluation and type detection for JSON values.

    Type Parameters

    • T = any

      The expected type of the value

    • K extends string = string

      The key type for object properties (defaults to string)

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new JsonValue entity.

      Type Parameters

      • T = any

        The expected type of the value

      • K extends string = string

        The key type for object properties (defaults to string)

      Parameters

      • Optionalbuffer: ByteStream | ByteBuffer

        Optional ByteBuffer or ByteStream to read from

      • Optionalkey: JsonString<K>

        Optional key associated with this value (for object members)

      Returns JsonValue<T, K>

    Properties

    buffer: ByteBuffer
    consumed: boolean = false

    Accessors

    • get bufferLength(): number

      Gets the current length of the buffer.

      Returns number

      The number of bytes in the buffer

    • get entityType(): string

      Gets the type name of this entity.

      Returns string

      The constructor name of this entity

    • set maxBufferSize(size: number): void

      Sets the maximum buffer size before compaction occurs.

      Parameters

      • size: number

        The maximum buffer size in bytes

      Returns void

    Methods

    • Reads and fully evaluates the value.

      Returns T

      The actual JavaScript value (string, number, boolean, null, object, or array)

    • Asynchronously reads and fully evaluates the value.

      Returns Promise<T>

      A promise that resolves to the actual JavaScript value

    • Attempts to parse by executing a callback, reverting buffer state on failure.

      Type Parameters

      Parameters

      • cb: (entity: this) => T

        The callback function to execute

      Returns T | undefined

      The result of the callback, or undefined if parsing needs more data

      Error if the entity has already been consumed