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 @see \io\vertx\jphp\core\parsetools\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.

package

Default

Methods

__construct

__construct() 

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

arrayEventMode() : $this

Response

$this

a reference to this, so the API can be used fluently

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

arrayValueMode() : $this

Json array currently streamed won't be affected.

Response

$this

a reference to this, so the API can be used fluently

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

end() : void

endHandler

endHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

exceptionHandler

exceptionHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

fetch

fetch( $arg0) : $this

Arguments

$arg0

integer

Response

$this

Something has happened, so handle it.

handle( $arg0) : void

Arguments

$arg0

Buffer

handler

handler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

Create a new <code>JsonParser</code> instance.

newParser( $arg0 = null) : \io\vertx\jphp\core\parsetools\JsonParser
static

newParser()

Create a new JsonParser instance.

param $stream [ReadStream] newParser($stream)

Arguments

$arg0

ReadStream

Response

\io\vertx\jphp\core\parsetools\JsonParser

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

objectEventMode() : $this

Response

$this

a reference to this, so the API can be used fluently

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

objectValueMode() : $this

Json object currently streamed won't be affected.

Response

$this

a reference to this, so the API can be used fluently

pause

pause() : $this

Response

$this

resume

resume() : $this

Response

$this

Handle a <code>Buffer</code>, pretty much like calling {@link io.vertx.core.Handler}.

write( $arg0) : $this

Arguments

$arg0

Buffer

Response

$this

a reference to this, so the API can be used fluently