Add a fragment
of additional JSON text to the overall conceptual string
being parsed.
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).
Stop feeding fragments to this parser and compute and return the final parse result.
The overall parse result if the concatenated fragments constitute valid JSON text.
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
).
The overall parse result if the concatenated fragments constitute valid
JSON text, as modified by reviver
.
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, callfinish()
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)
orfinish()
will throw aSyntaxError
.