jawn

package jawn

Visibility
  1. Public
  2. All

Type Members

  1. final class AsyncParser[J] extends ByteBasedParser[J]

    AsyncParser is able to parse chunks of data (encoded as Option[ByteBuffer] instances) and parse asynchronously.

    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.

  2. trait ByteBasedParser[J] extends Parser[J]

    Trait used when the data to be parsed is in UTF-8.

    Trait used when the data to be parsed is in UTF-8.

    This parser has to translate input bytes to Chars and Strings. It provides a byte() method to access individual bytes, and also parser strings from bytes.

    Its parseString() implementation has two cases. In the first case (the hot path) the string has no escape sequences and we can just UTF-8 decode the entire set of bytes. In the second case, it goes to some trouble to be sure to de-escape correctly given that the input data is UTF-8.

  3. final class ByteBufferParser[J] extends SyncParser[J] with ByteBasedParser[J]

    Basic ByteBuffer parser.

    Basic ByteBuffer parser.

    This assumes that the provided ByteBuffer is ready to be read. The user is responsible for any necessary flipping/resetting of the ByteBuffer before parsing.

    The parser makes absolute calls to the ByteBuffer, which will not update its own mutable position fields.

  4. final class ChannelParser[J] extends SyncParser[J] with ByteBasedParser[J]

    Basic file parser.

    Basic file parser.

    Given a file name this parser opens it, chunks the data 256K at a time, and parses it.

  5. trait FContext[J] extends AnyRef

    FContext is used to construct nested JSON values.

    FContext is used to construct nested JSON values.

    The most common cases are to build objects and arrays. However, this type is also used to build a single top-level JSON element, in cases where the entire JSON document consists of "333.33".

  6. trait Facade[J] extends AnyRef

    Facade is a type class that describes how Jawn should construct JSON AST elements of type J.

    Facade is a type class that describes how Jawn should construct JSON AST elements of type J.

    Facade[J] also uses FContext[J] instances, so implementors will usually want to define both.

  7. case class IncompleteParseException(msg: String) extends Exception with Product with Serializable

  8. trait MutableFacade[J] extends Facade[J]

  9. case class ParseException(msg: String, index: Int, line: Int, col: Int) extends Exception with Product with Serializable

  10. trait Parser[J] extends AnyRef

    Parser implements a state machine for correctly parsing JSON data.

    Parser implements a state machine for correctly parsing JSON data.

    The trait relies on a small number of methods which are left abstract, and which generalize parsing based on whether the input is in Bytes or Chars, coming from Strings, files, or other input. All methods provided here are protected, so different parsers can choose which functionality to expose.

    Parser is parameterized on J, which is the type of the JSON AST it will return. Jawn can produce any AST for which a Facade[J] is available.

    The parser trait does not hold any state itself, but particular implementations will usually hold state. Parser instances should not be reused between parsing runs.

    For now the parser requires input to be in UTF-8. This requirement may eventually be relaxed.

  11. trait SimpleFacade[J] extends Facade[J]

    Facade is a type class that describes how Jawn should construct JSON AST elements of type J.

    Facade is a type class that describes how Jawn should construct JSON AST elements of type J.

    Facade[J] also uses FContext[J] instances, so implementors will usually want to define both.

  12. trait SupportParser[J] extends AnyRef

  13. trait SyncParser[J] extends Parser[J]

    SyncParser extends Parser to do all parsing synchronously.

    SyncParser extends Parser to do all parsing synchronously.

    Most traditional JSON parser are synchronous, and expect to receive all their input before returning. SyncParser[J] still leaves Parser[J]'s methods abstract, but adds two public methods for users to call to actually parse JSON.

Value Members

  1. object AsyncParser

  2. object ChannelParser

  3. object NullFacade extends Facade[Unit]

    NullFacade discards all JSON AST information.

    NullFacade discards all JSON AST information.

    This is the simplest possible facade. It could be useful for checking JSON for correctness (via parsing) without worrying about saving the data.

    It will always return () on any successful parse, no matter the content.

  4. object Parser

Ungrouped