package core
- Alphabetic
- Public
- Protected
Type Members
- case class Abort(msg: String) extends Exception with Product with Serializable
Throw this inside a Visitor's handler functions to fail the processing of JSON.
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.
- case class AbortException(clue: String, index: Int, line: Int, col: Int, cause: Throwable) extends Exception with Product with Serializable
Signals failure processsing JSON after parsing.
- trait Annotator extends AnyRef
- trait ArrVisitor[-T, +J] extends ObjArrVisitor[T, J]
Visits the elements of a json array.
- trait BufferingByteParser extends AnyRef
Models a growable buffer of Bytes, which are Chars or Bytes.
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 elem-by-elem 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 batchNote 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)
- trait BufferingCharParser extends AnyRef
Models a growable buffer of Chars, which are Chars or Bytes.
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 elem-by-elem 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 batchNote 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)
- trait BufferingInputStreamParser extends BufferingByteParser
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 .
- abstract class ByteAppendC extends AnyRef
- class ByteBuilder 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
andappendUnsafe
separately, e.g. callignensureLength
once beforeappendUnsafe
-ing multiple Bytes - It provides fast methods like makeString or writeOutToIfLongerThan, that let you push the data elsewhere with minimal unnecessary copying - abstract class CharAppendC extends AnyRef
- class CharBuilder 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
andappendUnsafe
separately, e.g. callignensureLength
once beforeappendUnsafe
-ing multiple Chars - It provides fast methods like makeString or writeOutToIfLongerThan, that let you push the data elsewhere with minimal unnecessary copying - class LogVisitor[-T, +V] extends Visitor[T, V]
A visitor that wraps another but prints out what methods get called, useful for debugging
- sealed trait ObjArrVisitor[-T, +J] extends AnyRef
Base class for visiting elements of json arrays and objects.
Base class for visiting elements of json arrays and objects.
- T
???
- J
the result of visiting elements (e.g. a json AST or side-effecting writer)
- trait ObjVisitor[-T, +J] extends ObjArrVisitor[T, J]
Visits the elements of a json object.
- 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.
- class TraceVisitor[T, J] extends Delegate[T, J]
- trait Types extends AnyRef
Basic functionality to be able to read and write objects.
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 - trait Visitor[-T, +J] extends AnyRef
Standard set of hooks uPickle uses to traverse over a structured data.
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
'slength
is not set when parsing JSON input (since it cannot be known up front) and the variousindex
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 tovisitFloat64
- T
???
- J
the result of visiting elements (e.g. a json AST or side-effecting writer)
- class WrapByteArrayCharSeq extends CharSequence
A CharSequence that wraps an array of elements without any copying.
A CharSequence that wraps an array of elements 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. - class WrapCharArrayCharSeq extends CharSequence
A CharSequence that wraps an array of elements without any copying.
A CharSequence that wraps an array of elements 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.
Value Members
- object BufferingInputStreamParser
- object ByteOps
- object CharOps
- 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.
- object RenderUtils
- object StringVisitor extends SimpleVisitor[Nothing, Any]
- 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.
- See also
https://goessner.net/articles/JsonPath/
- object Util
- object Visitor