Util.Json.JsonPath
case JsonPath(List[JsonStep])A path locating a value inside a Json document, as a sequence of
JsonSteps.
The List[JsonStep] is stored head-at-root: the first element is the
outermost step and the last element is the leaf. Walking head-to-tail
yields the natural root-to-leaf order used by toJsonPointer.
Definitions
def cons(s: JsonStep, p: JsonPath): JsonPath
SourcePrepends s to p. O(1).
This is the decode-side primitive: as a decode error bubbles up, each
outer wrapper conses its own step, leaving the head as the outermost
(root) step.
def empty(): JsonPath
SourceReturns the empty path (the root).
def fromJsonPointer(s: String): Option[JsonPath]
SourceParses a JSON Pointer (RFC 6901) into a JsonPath.
Returns None if s is non-empty and does not start with /, or if a
reference token contains an invalid ~ escape.
All-digit segments without leading zeros (or the lone segment "0")
classify as Index; everything else classifies as Key. This is a
heuristic — round-tripping a Key("123") through toJsonPointer then
fromJsonPointer yields Index(123).
def fromList(xs: List[JsonStep]): JsonPath
SourceReturns a path with the given steps in root-to-leaf order.
def snoc(p: JsonPath, s: JsonStep): JsonPath
SourceAppends s to p. O(n).
This is the navigation-side primitive: when constructing a path forward from the root, each new step extends the leaf end.
def steps(p: JsonPath): List[JsonStep]
SourceReturns the steps of p in root-to-leaf order.
def toJsonPointer(p: JsonPath): String
SourceRenders p as a JSON Pointer (RFC 6901).
The empty path is rendered as the empty string. A non-empty path is
rendered as /-separated reference tokens, where keys are escaped per
RFC 6901 (~ -> ~0, / -> ~1) and indices are rendered in decimal.