upickle.core

package upickle.core

Members list

Packages

Type members

Classlikes

case class Abort(msg: String) extends Exception

Throw this inside a Visitor's handler functions to fail the processing of JSON. The Facade just needs to provide the error message, and it is up to the driver to ensure it is properly wrapped in a AbortException with the relevant source information.

Throw this inside a Visitor's handler functions to fail the processing of JSON. The Facade just needs to provide the error message, and it is up to the driver to ensure it is properly wrapped in a AbortException with the relevant source information.

Attributes

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
case class AbortException(clue: String, index: Int, line: Int, col: Int, cause: Throwable) extends Exception

Signals failure processsing JSON after parsing.

Signals failure processsing JSON after parsing.

Attributes

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
trait ArrVisitor[-T, +J] extends ObjArrVisitor[T, J]

Visits the elements of a json array.

Visits the elements of a json array.

Attributes

Supertypes
trait ObjArrVisitor[T, J]
class Object
trait Matchable
class Any
Known subtypes
class MapArrContext[T, V, Z]

Models a growable buffer of Bytes, which are Chars or Bytes. We maintain an Array[Byte] as a buffer, and read Bytes into it using readDataIntoBuffer and drop old Bytes using dropBufferUntil.

Models a growable buffer of Bytes, which are Chars or Bytes. We maintain an Array[Byte] as a buffer, and read Bytes into it using readDataIntoBuffer and drop old Bytes using dropBufferUntil.

In general, BufferingByteParser allows us to keep the fast path fast:

  • Reading byte-by-byte from the buffer is a bounds check and direct Array access, without any indirection or polymorphism.
  • We load Bytes in batches into the buffer, which allows us to take advantage of batching APIs like InputStream.read
  • We amortize the overhead of the indirect/polymorphic readDataIntoBuffer call over the size of each batch

Note that dropBufferUntil only advances a dropped index and does not actually zero out the dropped Bytes; instead, we wait until we need to call growBuffer, and use that as a chance to copy the remaining un-dropped Bytes to either the start of the current buffer or the start of a newly-allocated bigger buffer (if necessary)

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

Models a growable buffer of Chars, which are Chars or Bytes. We maintain an Array[Char] as a buffer, and read Chars into it using readDataIntoBuffer and drop old Chars using dropBufferUntil.

Models a growable buffer of Chars, which are Chars or Bytes. We maintain an Array[Char] as a buffer, and read Chars into it using readDataIntoBuffer and drop old Chars using dropBufferUntil.

In general, BufferingCharParser allows us to keep the fast path fast:

  • Reading char-by-char from the buffer is a bounds check and direct Array access, without any indirection or polymorphism.
  • We load Chars in batches into the buffer, which allows us to take advantage of batching APIs like InputStream.read
  • We amortize the overhead of the indirect/polymorphic readDataIntoBuffer call over the size of each batch

Note that dropBufferUntil only advances a dropped index and does not actually zero out the dropped Chars; instead, we wait until we need to call growBuffer, and use that as a chance to copy the remaining un-dropped Chars to either the start of the current buffer or the start of a newly-allocated bigger buffer (if necessary)

Attributes

Supertypes
class Object
trait Matchable
class Any

Defines common functionality to any parser that works on a java.io.InputStream

Defines common functionality to any parser that works on a java.io.InputStream

Allows you to look up individual bytes by index, take slices of byte ranges or strings, and drop old portions of buffered data once you are certain you no longer need them.

The buffer size is managed by allowing it to grow in size until it exceeds its capacity. When that happens, one of two things happen:

  • If the buffer has enough space, we left-shift the data in the buffer to over-write the portion that has already been dropped.

  • If the buffer does not have enough space, we allocate a new buffer big enough to hold the new data we need to store (size a power of two multiple of the old size) and copy the data over, again shifted left .

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class ByteAppendC

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class ByteBuilder
class ByteBuilder(startSize: Int) extends ByteAppendC

A fast buffer that can be used to store Bytes (Bytes or Chars).

A fast buffer that can be used to store Bytes (Bytes or Chars).

Generally faster than the equivalent StringBuilder or java.io.ByteArrayOutputStream, since:

  • It is specialized and without the overhead of polymorphism or synchronization.
  • It allows the user to call ensureLength and appendUnsafe separately, e.g. callign ensureLength once before appendUnsafe-ing multiple Bytes
  • It provides fast methods like makeString or writeOutToIfLongerThan, that let you push the data elsewhere with minimal unnecessary copying

Attributes

Supertypes
class ByteAppendC
class Object
trait Matchable
class Any
object ByteOps

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
ByteOps.type
object ByteUtils

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
ByteUtils.type
abstract class CharAppendC

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class CharBuilder
class CharBuilder(startSize: Int) extends CharAppendC

A fast buffer that can be used to store Chars (Bytes or Chars).

A fast buffer that can be used to store Chars (Bytes or Chars).

Generally faster than the equivalent StringBuilder or java.io.ByteArrayOutputStream, since:

  • It is specialized and without the overhead of polymorphism or synchronization.
  • It allows the user to call ensureLength and appendUnsafe separately, e.g. callign ensureLength once before appendUnsafe-ing multiple Chars
  • It provides fast methods like makeString or writeOutToIfLongerThan, that let you push the data elsewhere with minimal unnecessary copying

Attributes

Supertypes
class CharAppendC
class Object
trait Matchable
class Any
object CharOps

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
CharOps.type
object CharUtils

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
CharUtils.type

Implicit to indicate that we are currently deriving an implicit T. Used to avoid the implicit being derived from picking up its own definition, resulting in infinite looping/recursion

Implicit to indicate that we are currently deriving an implicit T. Used to avoid the implicit being derived from picking up its own definition, resulting in infinite looping/recursion

Attributes

Supertypes
class Object
trait Matchable
class Any
class LinkedHashMap[K, V] extends Map[K, V], LinkedHashMapCompat[K, V]

mutable.Map[K, V] implementation wrapping a java.util.LinkedHashMap[K, V] which doesn't allow null as key. Useful since the java.util implementation is safe from hash-collision attacks.

mutable.Map[K, V] implementation wrapping a java.util.LinkedHashMap[K, V] which doesn't allow null as key. Useful since the java.util implementation is safe from hash-collision attacks.

Attributes

Companion
object
Supertypes
trait LinkedHashMapCompat[K, V]
trait Map[K, V]
trait MapOps[K, V, Map, Map[K, V]]
trait Shrinkable[K]
trait Builder[(K, V), Map[K, V]]
trait Growable[(K, V)]
trait Clearable
trait Cloneable[Map[K, V]]
trait Cloneable
trait Map[K, V]
trait Equals
trait MapFactoryDefaults[K, V, Map, Iterable]
trait MapOps[K, V, Map, Map[K, V]]
trait PartialFunction[K, V]
trait K => V
trait Iterable[(K, V)]
trait Iterable[(K, V)]
trait IterableFactoryDefaults[(K, V), Iterable]
trait IterableOps[(K, V), Iterable, Map[K, V]]
trait IterableOnceOps[(K, V), Iterable, Map[K, V]]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
object LinkedHashMap

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
class LogVisitor[-T, +V](downstream: Visitor[T, V], log: String => Unit, indent: String) extends Visitor[T, V]

A visitor that wraps another but prints out what methods get called, useful for debugging

A visitor that wraps another but prints out what methods get called, useful for debugging

Attributes

Supertypes
trait Visitor[T, V]
class Object
trait Matchable
class Any
object NoOpVisitor extends Visitor[Unit, 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.

Attributes

Supertypes
trait Visitor[Unit, Unit]
class Object
trait Matchable
class Any
Self type
sealed trait ObjArrVisitor[-T, +J]

Base class for visiting elements of json arrays and objects.

Base class for visiting elements of json arrays and objects.

Type parameters

J

the result of visiting elements (e.g. a json AST or side-effecting writer)

T

???

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait ArrVisitor[T, J]
class MapArrContext[T, V, Z]
trait ObjVisitor[T, J]
class MapObjContext[T, V, Z]
trait ObjVisitor[-T, +J] extends ObjArrVisitor[T, J]

Visits the elements of a json object.

Visits the elements of a json object.

Attributes

Supertypes
trait ObjArrVisitor[T, J]
class Object
trait Matchable
class Any
Known subtypes
class MapObjContext[T, V, Z]
object ParseUtils

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
ParseUtils.type
object RenderUtils

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
trait SimpleVisitor[-T, +V] extends Visitor[T, V]

A visitor that throws an error for all the visit methods which it does not define, letting you only define the handlers you care about.

A visitor that throws an error for all the visit methods which it does not define, letting you only define the handlers you care about.

Attributes

Supertypes
trait Visitor[T, V]
class Object
trait Matchable
class Any
Known subtypes
object StringVisitor.type
trait SimpleReader[T]
trait TaggedReadWriter[T]
class Leaf[T]
class Node[T]
trait TaggedReader[T]
class Leaf[T]
class Node[T]
Show all
object StringVisitor extends SimpleVisitor[Nothing, Any]

Attributes

Supertypes
trait SimpleVisitor[Nothing, Any]
trait Visitor[Nothing, Any]
class Object
trait Matchable
class Any
Self type
object TraceVisitor

Adds a JSON Path to exceptions thrown by the delegate Visitor.

Adds a JSON Path to exceptions thrown by the delegate Visitor.

Useful for debugging failures. Adds ~10% overhead depending on the parser.

Attributes

See also
Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
class TraceVisitor[T, J](val delegate: Visitor[T, J], parentPath: HasPath, wrapper: Wrapper[T, J]) extends Delegate[T, J]

Attributes

Companion
object
Supertypes
class Delegate[T, J]
trait Visitor[T, J]
class Object
trait Matchable
class Any
trait Types

Basic functionality to be able to read and write objects. Kept as a trait so other internal files can use it, while also mixing it into the upickle package to form the public API1

Basic functionality to be able to read and write objects. Kept as a trait so other internal files can use it, while also mixing it into the upickle package to form the public API1

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
trait Visitor[-T, +J]

Standard set of hooks uPickle uses to traverse over a structured data. A superset of the JSON, MessagePack, and Scala object hierarchies, since it needs to support efficiently processing all of them.

Standard set of hooks uPickle uses to traverse over a structured data. A superset of the JSON, MessagePack, and Scala object hierarchies, since it needs to support efficiently processing all of them.

Note that some parameters are un-set (-1) when not available; e.g. visitArray's length is not set when parsing JSON input (since it cannot be known up front) and the various index parameters are not set when traversing Scala object hierarchies.

When expecting to deal with a subset of the methods; it is common to forward the ones you don't care about to the ones you do; e.g. JSON visitors would forward all visitFloat32/visitInt/etc. methods to visitFloat64

Type parameters

J

the result of visiting elements (e.g. a json AST or side-effecting writer)

T

???

Attributes

See also
Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class LogVisitor[T, V]
object NoOpVisitor.type
trait SimpleVisitor[T, V]
object StringVisitor.type
trait SimpleReader[T]
trait TaggedReadWriter[T]
class Leaf[T]
class Node[T]
trait TaggedReader[T]
class Leaf[T]
class Node[T]
trait Reader[T]
trait ReadWriter[T]
class Delegate[T]
class Delegate[T, V]
class MapReader[T, V, Z]
class Delegate[T, V]
class TraceVisitor[T, J]
class MapReader[T, V, Z]
Show all
object Visitor

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Visitor.type
class WrapByteArrayCharSeq(arr: Array[Byte], start: Int, length0: Int) extends CharSequence

A CharSequence that wraps an array of byteents without any copying.

A CharSequence that wraps an array of byteents without any copying.

Note that the arr is mutable, and so the WrapByteArrayCharSeq should not itself be stored: either use it immediately when given it or call .toString if you want to store the data for later use.

Attributes

Supertypes
trait CharSequence
class Object
trait Matchable
class Any
class WrapCharArrayCharSeq(arr: Array[Char], start: Int, length0: Int) extends CharSequence

A CharSequence that wraps an array of charents without any copying.

A CharSequence that wraps an array of charents without any copying.

Note that the arr is mutable, and so the WrapCharArrayCharSeq should not itself be stored: either use it immediately when given it or call .toString if you want to store the data for later use.

Attributes

Supertypes
trait CharSequence
class Object
trait Matchable
class Any