Package

com.github.plokhotnyuk.jsoniter_scala

core

Permalink

package core

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. core
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait JsonCodec[A] extends JsonValueCodec[A] with JsonKeyCodec[A]

    Permalink
  2. trait JsonKeyCodec[A] extends AnyRef

    Permalink
  3. final class JsonReader extends AnyRef

    Permalink
  4. class JsonReaderException extends RuntimeException

    Permalink
  5. trait JsonValueCodec[A] extends AnyRef

    Permalink
  6. final class JsonWriter extends AnyRef

    Permalink
  7. class JsonWriterException extends RuntimeException

    Permalink
  8. case class ReaderConfig(throwReaderExceptionWithStackTrace: Boolean = false, appendHexDumpToParseException: Boolean = true, preferredBufSize: Int = 16384, preferredCharBufSize: Int = 1024) extends Product with Serializable

    Permalink

    Configuration for com.github.plokhotnyuk.jsoniter_scala.core.JsonReader that contains flags for tuning of parsing exceptions and preferred sizes for internal buffers that created on the reader instantiation and reused in runtime for parsing of messages.

    Configuration for com.github.plokhotnyuk.jsoniter_scala.core.JsonReader that contains flags for tuning of parsing exceptions and preferred sizes for internal buffers that created on the reader instantiation and reused in runtime for parsing of messages.
    All configuration params already initialized by recommended default values, but in some cases they should be altered for performance reasons:

    • turn off stack traces for parsing exceptions to greatly reduce impact on performance for cases when exceptions can be not exceptional (e.g. under DoS attacks over open to the world systems), see more details here: https://shipilev.net/blog/2014/exceptional-performance/
    • turn off appending of hex dump to minimize length of exception message
    • increase preferred size of an internal char buffer to reduce allocation rate of grown and then reduced buffers when large (>1Kb) string instances need to be parsed
    • increase preferred size of an internal byte buffer for parsing from java.io.InputStream or java.nio.DirectByteBuffer to reduce allocation rate of grown and then reduced buffers during parsing of large (>16Kb) scala.math.BigDecimal, scala.math.BigInt or ADT instances with the discriminator field doesn't appear in the beginning of the JSON object
    throwReaderExceptionWithStackTrace

    a flag that allows to turn on a stack traces for debugging purposes in development

    appendHexDumpToParseException

    a flag that allows to turn off hex dumping of affected by error part of an internal byte buffer

    preferredBufSize

    a preferred size (in bytes) of an internal byte buffer when parsing from java.io.InputStream

    preferredCharBufSize

    a preferred size (in chars) of an internal char buffer for parsing of string values

  9. case class WriterConfig(throwWriterExceptionWithStackTrace: Boolean = false, indentionStep: Int = 0, escapeUnicode: Boolean = false, preferredBufSize: Int = 16384) extends Product with Serializable

    Permalink

    Configuration for com.github.plokhotnyuk.jsoniter_scala.core.JsonWriter that contains params for formatting of output JSON and for tuning of preferred size for internal byte buffer that is created on the writer instantiation and reused in runtime for serialization of messages using java.io.OutputStream or java.nio.DirectByteBuffer.

    Configuration for com.github.plokhotnyuk.jsoniter_scala.core.JsonWriter that contains params for formatting of output JSON and for tuning of preferred size for internal byte buffer that is created on the writer instantiation and reused in runtime for serialization of messages using java.io.OutputStream or java.nio.DirectByteBuffer.
    All configuration params already initialized to default values, but in some cases they should be altered:

    • turn on pretty printing by specifying of indention step that is greater than 0
    • turn on escaping of Unicode characters to serialize with only ASCII characters
    • increase preferred size of an internal byte buffer to reduce allocation rate of grown and then reduced buffers when writing to java.io.OutputStream or java.nio.DirectByteBuffer lot of large (>16Kb) scala.math.BigDecimal, scala.math.BigInt or other non escaped ASCII strings written using JsonWriter.writeNonEscapedAsciiKey or JsonWriter.writeNonEscapedAsciiVal
    throwWriterExceptionWithStackTrace

    a flag that allows to turn on a stack traces for debugging purposes in development

    indentionStep

    a size of indention for pretty-printed formatting or 0 for compact output

    escapeUnicode

    a flag to turn on hexadecimal escaping of all non-ASCII chars

    preferredBufSize

    a preferred size (in bytes) of an internal byte buffer when writing to java.io.OutputStream or java.nio.DirectByteBuffer

Value Members

  1. object JsonReader

    Permalink
  2. object JsonWriter

    Permalink
  3. final def readFromArray[A](buf: Array[Byte], config: ReaderConfig = readerConfig)(implicit codec: JsonValueCodec[A]): A

    Permalink

    Deserialize JSON content encoded in UTF-8 from a byte array into a value of given A type with specified parsing options.

    Deserialize JSON content encoded in UTF-8 from a byte array into a value of given A type with specified parsing options.

    A

    type of the value to parse

    buf

    the byte array to parse from

    config

    a parsing configuration

    codec

    a codec for the given A type

    returns

    a successfully parsed value

    Exceptions thrown

    JsonReaderException if underlying input contains malformed UTF-8 bytes, invalid JSON content or the input JSON structure does not match structure that expected for result type, also in case if end of input is detected while some input bytes are expected

    java.lang.NullPointerException if the codec, buf or config is null

  4. final def readFromByteBuffer[A](bbuf: ByteBuffer, config: ReaderConfig = readerConfig)(implicit codec: JsonValueCodec[A]): A

    Permalink

    Deserialize JSON content encoded in UTF-8 from a byte buffer into a value of given A type with specified parsing options or with defaults that maximize description of error.

    Deserialize JSON content encoded in UTF-8 from a byte buffer into a value of given A type with specified parsing options or with defaults that maximize description of error.

    Parsing will start from the current position and will continue until the limit of the provided byte buffer or the value will be parsed before reaching of the limit. In any case the buffer position will be set to the next position after the last read byte.

    A

    type of the value to parse

    bbuf

    the byte buffer which will be parsed

    config

    a parsing configuration

    codec

    a codec for the given A type

    returns

    a successfully parsed value

    Exceptions thrown

    JsonReaderException if underlying input contains malformed UTF-8 bytes, invalid JSON content or the input JSON structure does not match structure that expected for the result type, also in case if end of input is detected while some input bytes are expected

    java.lang.NullPointerException if the codec, bbuf or config is null

  5. final def readFromStream[A](in: InputStream, config: ReaderConfig = readerConfig)(implicit codec: JsonValueCodec[A]): A

    Permalink

    Deserialize JSON content encoded in UTF-8 from an input stream into a value of given A type.

    Deserialize JSON content encoded in UTF-8 from an input stream into a value of given A type.

    A

    type of the value to parse

    in

    the input stream to parse from

    config

    a parsing configuration

    codec

    a codec for the given A type

    returns

    a successfully parsed value

    Exceptions thrown

    JsonReaderException if underlying input contains malformed UTF-8 bytes, invalid JSON content or the input JSON structure does not match structure that expected for result type, also if a low-level I/O problem (unexpected end-of-input, network error) occurs while some input bytes are expected

    java.lang.NullPointerException if the codec, in or config is null

  6. final def readFromString[A](s: String, config: ReaderConfig = readerConfig)(implicit codec: JsonValueCodec[A]): A

    Permalink

    Deserialize JSON content from a string into a value of given A type with specified parsing options or with defaults that maximize description of error.

    Deserialize JSON content from a string into a value of given A type with specified parsing options or with defaults that maximize description of error.

    While it much less efficient than parsing from a byte array using pooled readers but it can be safely used internally in custom codecs.

    A

    type of the value to parse

    s

    a value of string which will be parsed

    config

    a parsing configuration

    codec

    a codec for the given A type

    returns

    a successfully parsed value

    Exceptions thrown

    JsonReaderException if underlying input contains invalid JSON content or the input JSON structure does not match structure that expected for the result type, also in case if end of input is detected while some input characters are expected

    java.lang.NullPointerException if the codec, s or config is null

  7. final def readFromSubArray[A](buf: Array[Byte], from: Int, to: Int, config: ReaderConfig = readerConfig)(implicit codec: JsonValueCodec[A]): A

    Permalink

    Deserialize JSON content encoded in UTF-8 from a byte array into a value of given A type with specified parsing options or with defaults that maximize description of error.

    Deserialize JSON content encoded in UTF-8 from a byte array into a value of given A type with specified parsing options or with defaults that maximize description of error.

    A

    type of the value to parse

    buf

    the byte array to parse from

    from

    the start position of the provided byte array

    to

    the position of end of input in the provided byte array

    config

    a parsing configuration

    codec

    a codec for the given A type

    returns

    a successfully parsed value

    Exceptions thrown

    JsonReaderException if underlying input contains malformed UTF-8 bytes, invalid JSON content or the input JSON structure does not match structure that expected for result type, also in case if end of input is detected while some input bytes are expected

    java.lang.ArrayIndexOutOfBoundsException if the to is greater than buf length or negative, or from is greater than to or negative

    java.lang.NullPointerException if the codec, buf or config is null

  8. final def scanJsonArrayFromStream[A](in: InputStream, config: ReaderConfig = readerConfig)(f: (A) ⇒ Boolean)(implicit codec: JsonValueCodec[A]): Unit

    Permalink

    Deserialize JSON array encoded in UTF-8 from an input stream into its values of given A type.

    Deserialize JSON array encoded in UTF-8 from an input stream into its values of given A type.

    All parsed values will be passed to consuming function f.

    A

    type of the value to parse

    in

    the input stream to parse from

    config

    a parsing configuration

    f

    a consumer of values, that returns true to continue scanning or false to complete it

    codec

    a codec for the given A type

    returns

    a successfully parsed value

    Exceptions thrown

    JsonReaderException if underlying input contains malformed UTF-8 bytes, invalid JSON content or the input JSON structure does not match structure that expected for result type, also if a low-level I/O problem (unexpected end-of-input, network error) occurs while some input bytes are expected

    java.lang.NullPointerException if the codec, in or config is null

    java.lang.Throwable if some error was thrown by f() call

  9. final def scanJsonValuesFromStream[A](in: InputStream, config: ReaderConfig = readerConfig)(f: (A) ⇒ Boolean)(implicit codec: JsonValueCodec[A]): Unit

    Permalink

    Deserialize JSON of streaming values encoded in UTF-8 from an input stream into values of given A type.

    Deserialize JSON of streaming values encoded in UTF-8 from an input stream into values of given A type.

    All parsed values will be passed to consuming function f.

    A

    type of the value to parse

    in

    the input stream to parse from

    config

    a parsing configuration

    f

    a consumer of values, that returns true to continue scanning or false to complete it

    codec

    a codec for the given A type

    returns

    a successfully parsed value

    Exceptions thrown

    JsonReaderException if underlying input contains malformed UTF-8 bytes, invalid JSON content or the input JSON structure does not match structure that expected for result type, also if a low-level I/O problem (unexpected end-of-input, network error) occurs while some input bytes are expected

    java.lang.NullPointerException if the codec, in or config is null

    java.lang.Throwable if some error was thrown by f() call

  10. final def writeToArray[A](x: A, config: WriterConfig = writerConfig)(implicit codec: JsonValueCodec[A]): Array[Byte]

    Permalink

    Serialize the x argument to a new allocated instance of byte array in UTF-8 encoding of JSON format, that specified by provided configuration options.

    Serialize the x argument to a new allocated instance of byte array in UTF-8 encoding of JSON format, that specified by provided configuration options.

    A

    type of value to serialize

    x

    the value to serialize

    config

    a serialization configuration

    codec

    a codec for the given value

    returns

    a byte array with x serialized to JSON

    Exceptions thrown

    JsonWriterException if the value to serialize contains strings, double or float values which cannot be properly encoded

    java.lang.NullPointerException if the codec or config is null

  11. final def writeToByteBuffer[A](x: A, bbuf: ByteBuffer, config: WriterConfig = writerConfig)(implicit codec: JsonValueCodec[A]): Unit

    Permalink

    Serialize the x argument to the given instance of byte buffer in UTF-8 encoding of JSON format that specified by provided configuration options or defaults that minimizes output size & time to serialize.

    Serialize the x argument to the given instance of byte buffer in UTF-8 encoding of JSON format that specified by provided configuration options or defaults that minimizes output size & time to serialize.

    Serialization will start from the current position up to the provided byte buffer limit. On return the byte buffer will has position set to the next position after the last written byte.

    A

    type of value to serialize

    x

    the value to serialize

    bbuf

    a byte buffer where the value should be serialized

    config

    a serialization configuration

    codec

    a codec for the given value

    Exceptions thrown

    JsonWriterException if the value to serialize contains strings, double or float values which cannot be properly encoded

    java.lang.NullPointerException if the codec, bbuf or config is null

    java.nio.BufferOverflowException if the bbuf limit was exceeded during serialization

    java.nio.ReadOnlyBufferException if the bbuf is read-only

  12. final def writeToStream[A](x: A, out: OutputStream, config: WriterConfig = writerConfig)(implicit codec: JsonValueCodec[A]): Unit

    Permalink

    Serialize the x argument to the provided output stream in UTF-8 encoding of JSON format that specified by provided configuration options.

    Serialize the x argument to the provided output stream in UTF-8 encoding of JSON format that specified by provided configuration options.

    A

    type of value to serialize

    x

    the value to serialize

    out

    an output stream to serialize into

    config

    a serialization configuration

    codec

    a codec for the given value

    Exceptions thrown

    JsonWriterException if the value to serialize contains strings, double or float values which cannot be properly encoded

    java.io.IOException if an I/O error occurs in a call to output stream

    java.lang.NullPointerException if the codec, out or config is null

  13. final def writeToString[A](x: A, config: WriterConfig = writerConfig)(implicit codec: JsonValueCodec[A]): String

    Permalink

    Serialize the x argument to a string in JSON format, that specified by provided configuration options.

    Serialize the x argument to a string in JSON format, that specified by provided configuration options.

    While it much less efficient than serialization to a byte array using pooled writers but it can be safely used internally in custom codecs.

    A

    type of value to serialize

    x

    the value to serialize

    config

    a serialization configuration

    codec

    a codec for the given value

    returns

    a string with x serialized to JSON

    Exceptions thrown

    JsonWriterException if the value to serialize contains strings, double or float values which cannot be properly encoded

    java.lang.NullPointerException if the codec or config is null

  14. final def writeToSubArray[A](x: A, buf: Array[Byte], from: Int, to: Int, config: WriterConfig = writerConfig)(implicit codec: JsonValueCodec[A]): Int

    Permalink

    Serialize the x argument to the given instance of byte array in UTF-8 encoding of JSON format that specified by provided configuration options or defaults that minimizes output size & time to serialize.

    Serialize the x argument to the given instance of byte array in UTF-8 encoding of JSON format that specified by provided configuration options or defaults that minimizes output size & time to serialize.

    A

    type of value to serialize

    x

    the value to serialize

    buf

    a byte array where the value should be serialized

    from

    a position in the byte array from which serialization of the value should start

    to

    an exclusive position in the byte array that limits where serialization of the value should stop

    config

    a serialization configuration

    codec

    a codec for the given value

    returns

    number of next position after last byte serialized to buf

    Exceptions thrown

    JsonWriterException if the value to serialize contains strings, double or float values which cannot be properly encoded

    java.lang.ArrayIndexOutOfBoundsException if the from is greater than to or negative, if 'to' is greater than buf length or to limit was exceeded during serialization

    java.lang.NullPointerException if the codec, buf or config is null

Inherited from AnyRef

Inherited from Any

Ungrouped