Options
All
  • Public
  • Public/Protected
  • All
Menu

Class JsonParser

A parser class which allows to incrementally parse json elements and emit json parse events instead of parsing a json element fully. This parser is convenient for parsing large json structures.

The parser also parses concatenated json streams or line delimited json streams.

The parser can also parse entire object or array when it is convenient, for instance a very large array of small objects can be parsed efficiently by handling array start/end and object events.

Whenever the parser fails to parse or process the stream, the {@link JsonParser#exceptionHandler} is called with the cause of the failure and the current handling stops. After such event, the parser should not handle data anymore.

Hierarchy

  • JsonParser

Implements

Index

Methods

arrayEventMode

  • Flip the parser to emit a stream of events for each new json array.

    Returns JsonParser

arrayValueMode

  • Flip the parser to emit a single value event for each new json array.

    Json array currently streamed won't be affected.

    Returns JsonParser

end

  • end(): void
  • End the stream, this must be called after all the json stream has been processed.

    Returns void

endHandler

  • endHandler(endHandler: ((res: void) => void) | Handler<void> | null | undefined): JsonParser
  • Parameters

    • endHandler: ((res: void) => void) | Handler<void> | null | undefined

    Returns JsonParser

exceptionHandler

  • Parameters

    Returns JsonParser

fetch

  • Parameters

    • amount: number

    Returns JsonParser

handle

  • Something has happened, so handle it.

    Parameters

    Returns void

handler

  • Parameters

    Returns JsonParser

objectEventMode

  • Flip the parser to emit a stream of events for each new json object.

    Returns JsonParser

objectValueMode

  • Flip the parser to emit a single value event for each new json object.

    Json object currently streamed won't be affected.

    Returns JsonParser

pause

pipe

  • Pause this stream and return a to transfer the elements of this stream to a destination .

    The stream will be resumed when the pipe will be wired to a WriteStream.

    Returns Pipe<JsonEvent>

pipeTo

  • Pipe this ReadStream to the WriteStream.

    Elements emitted by this stream will be written to the write stream until this stream ends or fails.

    Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

    Parameters

    Returns PromiseLike<void>

  • Pipe this ReadStream to the WriteStream.

    Elements emitted by this stream will be written to the write stream until this stream ends or fails.

    Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

    Parameters

    Returns void

resume

write

  • Handle a Buffer, pretty much like calling {@link Handler#handle}.

    Parameters

    Returns JsonParser

Static newParser

  • Create a new JsonParser instance.

    Returns JsonParser

  • Create a new JsonParser instance.

    Parameters

    Returns JsonParser

Generated using TypeDoc