Class: StreamingJsonParser
Defined in: core/dist/types/utils/streaming-parser.d.ts:19
StreamingJsonParser
Utility for extracting text from streaming JSON responses. Handles partial JSON, escape sequences, and incremental updates.
Example
const parser = new StreamingJsonParser('response');
// As JSON streams in...
parser.append('{"response":"Hello ');
parser.getText(); // "Hello "
parser.append('world"}');
parser.getText(); // "Hello world"
Constructors
Constructor
new StreamingJsonParser(
field?,debug?):StreamingJsonParser
Defined in: core/dist/types/utils/streaming-parser.d.ts:30
Parameters
field?
string
debug?
boolean
Returns
StreamingJsonParser
Methods
append()
append(
chunk):void
Defined in: core/dist/types/utils/streaming-parser.d.ts:34
Append a chunk of JSON to the buffer
Parameters
chunk
string
Returns
void
getNewText()
getNewText():
string
Defined in: core/dist/types/utils/streaming-parser.d.ts:47
Get only the new text since last call Returns empty string if no new content
Returns
string
getRaw()
getRaw():
string
Defined in: core/dist/types/utils/streaming-parser.d.ts:42
Get the raw extracted text (still escaped)
Returns
string
getText()
getText():
string
Defined in: core/dist/types/utils/streaming-parser.d.ts:38
Get the extracted text (unescaped, ready to display)
Returns
string
reset()
reset():
void
Defined in: core/dist/types/utils/streaming-parser.d.ts:51
Reset the parser state
Returns
void