com.rallyhealth.weepickle.v1.core

Type members

Classlikes

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 wrapped with relevant parser-level 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 wrapped with relevant parser-level information.

trait Annotator
trait ArrVisitor[-T, +J] extends ObjArrVisitor[T, J]

Visits the elements of a json array.

Visits the elements of a json array.

class CallbackVisitor[T, J](delegate: Visitor[T, J])(callback: J => Unit) extends Delegate[T, J]

Notifies the callback of top-level results returned by the delegate visitor.

Notifies the callback of top-level results returned by the delegate visitor.

Useful from extracting return values from visitors that are used in side-effecting positions.

trait FromInput

Input data, ready to push through a Visitor.

Input data, ready to push through a Visitor.

trait JsVisitor[-T, +J] extends Visitor[T, J]

A Visitor specialized to work with JSON types. Forwards the not-JSON-related methods to their JSON equivalents.

A Visitor specialized to work with JSON types. Forwards the not-JSON-related methods to their JSON equivalents.

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

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

JSON Pointer is standardized by RFC 6901 and commonly used by JSON Schema.

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

See also
object NoOpVisitor extends NoOpVisitor[Unit]

NoOpVisitor discards all JSON AST information.

NoOpVisitor discards all JSON AST information.

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

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

Companion
class
class NoOpVisitor[J](returnValue: J) extends Visitor[Any, J]
Companion
object
object NullVisitor extends NoOpVisitor[Null]

Visitor returning null for all instances. Useful in combination with side-effecting visitors, since null is a valid subtype of AnyRef.

Visitor returning null for all instances. Useful in combination with side-effecting visitors, since null is a valid subtype of AnyRef.

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 Params
J

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

T

input result of visiting a child of this object or array. object or array builders will typically insert this value into their internal Map or Seq.

trait ObjVisitor[-T, +J] extends ObjArrVisitor[T, J]

Visits the elements of a json object.

Visits the elements of a json object.

object Platform
trait SimpleVisitor[-T, +J] extends Visitor[T, J]

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.

object StringVisitor extends SimpleVisitor[Nothing, Any]
class TransformException(val shortMsg: String, val jsonPointer: String, val index: Option[Long], val line: Option[Long], val col: Option[Long], val token: Option[String], cause: Throwable) extends Exception

Enriches an exception with parser-level information. This could be a problem with either the parsing or with the Visitor consuming the data.

Enriches an exception with parser-level information. This could be a problem with either the parsing or with the Visitor consuming the data.

Value Params
col

column of text (if applicable) (1-indexed)

line

line of text (if applicable) (1-indexed)

shortMsg

free-text of what/where went wrong.

token

textual representation of the json token (if applicable)

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 com.rallyhealth.weepickle.v1 package to form the public API.

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 com.rallyhealth.weepickle.v1 package to form the public API.

object Util
trait Visitor[-T, +J] extends AutoCloseable

Standard set of hooks weepickle 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 weepickle 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 Params
J

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

T

the result of ObjArrVisitor.subVisitor which is passed back into a ArrVisitor and ObjVisitor via ObjArrVisitor.visitValue. For example, this might be a weejson.Str that gets passed into an ObjVisitor that's building up a weejson.Obj to be returned on ObjVisitor.visitEnd. Often T will be the same type as J for visitors that return things, or else Any by visitors that do their work by side-effecting instead of returning J.

See also
Companion
object
object Visitor
Companion
class