Class: JsonParser

vertx-js/json_parser~ JsonParser

new 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.

Source:

Methods

arrayEventMode() → {JsonParser}

Flip the parser to emit a stream of events for each new json array.
Source:
Returns:
a reference to this, so the API can be used fluently
Type
JsonParser

arrayValueMode() → {JsonParser}

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

Json array currently streamed won't be affected.
Source:
Returns:
a reference to this, so the API can be used fluently
Type
JsonParser

end()

End the stream, this must be called after all the json stream has been processed.
Source:

endHandler(endHandler) → {JsonParser}

Parameters:
Name Type Description
endHandler function
Source:
Returns:
Type
JsonParser

exceptionHandler(handler) → {JsonParser}

Parameters:
Name Type Description
handler function
Source:
Returns:
Type
JsonParser

handle(event)

Something has happened, so handle it.
Parameters:
Name Type Description
event Buffer the event to handle
Source:

handler(handler) → {JsonParser}

Parameters:
Name Type Description
handler function
Source:
Returns:
Type
JsonParser

objectEventMode() → {JsonParser}

Flip the parser to emit a stream of events for each new json object.
Source:
Returns:
a reference to this, so the API can be used fluently
Type
JsonParser

objectValueMode() → {JsonParser}

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

Json object currently streamed won't be affected.
Source:
Returns:
a reference to this, so the API can be used fluently
Type
JsonParser

pause() → {JsonParser}

Source:
Returns:
Type
JsonParser

resume() → {JsonParser}

Source:
Returns:
Type
JsonParser

write(buffer) → {JsonParser}

Handle a Buffer, pretty much like calling Handler#handle.
Parameters:
Name Type Description
buffer Buffer
Source:
Returns:
a reference to this, so the API can be used fluently
Type
JsonParser