Top Description Methods
io.vertx.core.parsetools

public Interface JsonParser

extends Handler<Buffer>, ReadStream<JsonEvent>
Known Direct Implementers
io.vertx.core.parsetools.impl.JsonParserImpl
Annotations
@VertxGen
Imports
io.vertx.codegen.annotations.Fluent, .VertxGen, io.vertx.core.Handler, io.vertx.core.buffer.Buffer, io.vertx.core.parsetools.impl.JsonParserImpl, io.vertx.core.streams.ReadStream

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 exceptionHandler(Handler) is called with the cause of the failure and the current handling stops. After such event, the parser should not handle data anymore.

Author
Julien Viet

Method Summary

Modifier and TypeMethod and Description
public JsonParser

Returns:

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

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

public JsonParser

Returns:

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

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

public void
end()

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

public JsonParser
endHandler(Handler<Void> endHandler)

public JsonParser
public JsonParser
fetch(long amount)

Redeclares io.vertx.core.streams.ReadStream.fetch.

Fetch the specified amount of elements.

public JsonParser
public static JsonParser
newParser()

Create a new JsonParser instance.

public static JsonParser
newParser(ReadStream<Buffer> stream)

Create a new JsonParser instance.

public JsonParser

Returns:

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

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

public JsonParser

Returns:

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

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

public JsonParser
pause()

Redeclares io.vertx.core.streams.ReadStream.pause.

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

public JsonParser
resume()

Redeclares io.vertx.core.streams.ReadStream.resume.

Resume reading, and sets the buffer in flowing mode.

public JsonParser

Returns:

a reference to this, so the API can be used fluently
write
(Buffer buffer)
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Handle a Buffer, pretty much like calling handle(Object).

Inherited from io.vertx.core.Handler:
handle
Inherited from io.vertx.core.streams.ReadStream:
collectendHandlerexceptionHandlerhandlerpipepipeTopipeTo

Method Detail

arrayEventModeback to summary
public JsonParser arrayEventMode()

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

Returns:JsonParser

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

Annotations
@Fluent
arrayValueModeback to summary
public JsonParser arrayValueMode()

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

Json array currently streamed won't be affected.
Returns:JsonParser

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

Annotations
@Fluent
endback to summary
public void end()

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

endHandlerback to summary
public JsonParser endHandler(Handler<Void> endHandler)
Annotations
@Fluent
exceptionHandlerback to summary
public JsonParser exceptionHandler(Handler<Throwable> handler)
Annotations
@Fluent
fetchback to summary
public JsonParser fetch(long amount)

Redeclares io.vertx.core.streams.ReadStream.fetch.

Doc from io.vertx.core.streams.ReadStream.fetch.

Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.

Returns:JsonParser

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

Annotations
@Override
handlerback to summary
public JsonParser handler(Handler<JsonEvent> handler)
Annotations
@Fluent
newParserback to summary
public static JsonParser newParser()

Create a new JsonParser instance.

newParserback to summary
public static JsonParser newParser(ReadStream<Buffer> stream)

Create a new JsonParser instance.

objectEventModeback to summary
public JsonParser objectEventMode()

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

Returns:JsonParser

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

Annotations
@Fluent
objectValueModeback to summary
public JsonParser objectValueMode()

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

Json object currently streamed won't be affected.
Returns:JsonParser

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

Annotations
@Fluent
pauseback to summary
public JsonParser pause()

Redeclares io.vertx.core.streams.ReadStream.pause.

Doc from io.vertx.core.streams.ReadStream.pause.

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

While it's paused, no data will be sent to the data handler.

Returns:JsonParser

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

Annotations
@Override
resumeback to summary
public JsonParser resume()

Redeclares io.vertx.core.streams.ReadStream.resume.

Doc from io.vertx.core.streams.ReadStream.resume.

Resume reading, and sets the buffer in flowing mode.

If the ReadStream has been paused, reading will recommence on it.

Returns:JsonParser

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

Annotations
@Override
writeback to summary
public JsonParser write(Buffer buffer)

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Handle a Buffer, pretty much like calling handle(Object).

Returns:JsonParser

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

Annotations
@Fluent