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

    Class JsonObject<T>

    Represents a JSON object. Provides streaming access to object members (key-value pairs).

    Type Parameters

    • T extends object = any

      The expected type of the object

    Hierarchy (View Summary)

    Index

    Constructors

    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

    • Returns an async iterator for object members. Enables use of for await...of loops on JsonObject.

      Returns AsyncGenerator<JsonObjectMember<T>, any, any>

    • Asynchronously consumes the entity by reading it if not already consumed.

      Returns Promise<void>

    • Generator that yields object members as key-value pairs. Allows for streaming/incremental processing of large objects.

      Returns Generator<JsonObjectMember<T>>

      Object containing the key and value entities for each member

    • Async generator that yields object members from a stream. Allows for asynchronous streaming/incremental processing.

      Returns AsyncGenerator<JsonObjectMember<T>>

      Object containing the key and value entities for each member

    • Reads and parses the entity, consuming it in the process.

      Returns T

      The parsed value

      Error if the entity has already been consumed

    • Asynchronously reads and parses the entity from a stream.

      Returns Promise<T>

      A promise that resolves to the parsed value

      Error if the entity has already been consumed

    • 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