@jswalden/streaming-json
    Preparing search index...

    Class StreamingJSONParser

    A JSON parser when you wish to incrementally parse your JSON in fragments, rather than from one complete string.

    Feed fragments of JSON text to the parser by calling add(fragment). When you've fed the entire JSON text to the parser, call finish() to get the (optionally revived) result.

    If the concatenation of added fragments becomes not a prefix of valid JSON text, or if the final concatenation of all fragments isn't valid JSON text, the applicable add(fragment) or finish() will throw a SyntaxError.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Add a fragment of additional JSON text to the overall conceptual string being parsed.

      Parameters

      • fragment: string

      Returns void

      SyntaxError if adding this fragment makes the concatenation of all fragments not a valid prefix of JSON text.

      Error (exactly, not a subclass) if fragments can't be added because a previous add(fragment) already threw or because finish() was called.

    • Return true if more fragments can be added to this parser and finish() hasn't been called. (Even if the concatenated fragments constitute a complete JSON text, fragments containing only whitespace can still be added.)

      Return false if no more fragments can be added (because finish() was called or because a previously-added fragment caused a JSON syntax error).

      Returns boolean

    • Stop feeding fragments to this parser and compute and return the final parse result.

      Returns JSONValue

      The overall parse result if the concatenated fragments constitute valid JSON text.

      Error if parsing was already done().

      SyntaxError if the concatenation of all added fragments (which could be the empty string if no fragments were added) isn't valid JSON. (It must be the prefix of valid JSON text or a preceding add(fragment) would have thrown.)

    • Stop feeding fragments to this parser, and compute the final parse result as the value unfiltered.

      Then apply reviver to unfiltered (and recursively to its properties and elements) exactly as JSON.parse would do if it passed reviver and the concatenation of fragments passed to this parser, and return the value JSON.parse would return (which will be the result returned by the outermost call of reviver).

      Type Parameters

      • T

      Parameters

      Returns T

      The overall parse result if the concatenated fragments constitute valid JSON text, as modified by reviver.

      Error if parsing was already done().

      SyntaxError if the concatenation of all added fragments (which could be the empty string if no fragments were added) isn't valid JSON. (It must be the prefix of valid JSON text or a preceding add(fragment) would have thrown.)

      Any value that reviver throws during the reviving process.