AsyncParser

org.typelevel.jawn.AsyncParser
See theAsyncParser companion object
final class AsyncParser[J] extends ByteBasedParser[J]

AsyncParser is able to parse chunks of data (encoded as Option[ByteBuffer] instances) and parse asynchronously. You can use the factory methods in the companion object to instantiate an async parser.

The async parser's fields are described below:

The (state, curr, stack) triple is used to save and restore parser state between async calls. State also helps encode extra information when streaming or unwrapping an array.

The (data, len, allocated) triple is used to manage the underlying data the parser is keeping track of. As new data comes in, data may be expanded if not enough space is available.

The offset parameter is used to drive the outer async parsing. It stores similar information to curr but is kept separate to avoid "corrupting" our snapshot.

The done parameter is used internally to help figure out when the atEof() parser method should return true. This will be set when apply(None) is called.

The streamMode parameter controls how the asynchronous parser will be handling multiple values. There are three states:

1: An array is being unwrapped. Normal JSON array rules apply (Note that if the outer value observed is not an array, this mode will toggle to the -1 mode).

0: A stream of individual JSON elements separated by whitespace are being parsed. We can return each complete element as we parse it.

-1: No streaming is occuring. Only a single JSON value is allowed.

Attributes

Companion
object
Source
AsyncParser.scala
Graph
Supertypes
trait ByteBasedParser[J]
class Parser[J]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

final def absorb(buf: ByteBuffer)(implicit facade: Facade[J]): Either[ParseException, Seq[J]]

Attributes

Source
AsyncParser.scala
final def absorb(bytes: Array[Byte])(implicit facade: Facade[J]): Either[ParseException, Seq[J]]

Attributes

Source
AsyncParser.scala
final def absorb(s: String)(implicit facade: Facade[J]): Either[ParseException, Seq[J]]

Attributes

Source
AsyncParser.scala
final def copy(): AsyncParser[J]

Attributes

Source
AsyncParser.scala
final def finalAbsorb(buf: ByteBuffer)(implicit facade: Facade[J]): Either[ParseException, Seq[J]]

Attributes

Source
AsyncParser.scala
final def finalAbsorb(bytes: Array[Byte])(implicit facade: Facade[J]): Either[ParseException, Seq[J]]

Attributes

Source
AsyncParser.scala
final def finalAbsorb(s: String)(implicit facade: Facade[J]): Either[ParseException, Seq[J]]

Attributes

Source
AsyncParser.scala
final def finish()(implicit facade: Facade[J]): Either[ParseException, Seq[J]]

Attributes

Source
AsyncParser.scala