JsonTraversal

dev.constructive.eo.circe.JsonTraversal
See theJsonTraversal companion object
final class JsonTraversal[A] extends Dynamic

Multi-focus counterpart to JsonPrism: walks the JSON to some array, then applies the focus update to every element. Two pieces: prefix: Array[PathStep] (root-to-array, walked once) and focus: JsonFocus[A] (per-element). The Leaf-vs-Fields split lives in focus. Compat alias JsonFieldsTraversal points back here.

Two tiers (Ior-bearing default + *Unsafe), same shape as JsonPrism.

Attributes

Companion
object
Source
JsonTraversal.scala
Graph
Supertypes
trait Dynamic
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

transparent inline def at(i: Int): Any
Extension method from JsonTraversal

.at(i) sugar — extend the suffix by an array index.

.at(i) sugar — extend the suffix by an array index.

Attributes

Source
JsonTraversal.scala
transparent inline def field[B](inline selector: A => B)(using encB: Encoder[B], decB: Decoder[B]): JsonTraversal[B]
Extension method from JsonTraversal

.field(_.x) sugar — extend the suffix by a named field.

.field(_.x) sugar — extend the suffix by a named field.

Attributes

Source
JsonTraversal.scala
transparent inline def fields(inline selectors: A => Any*): Any
Extension method from JsonTraversal

.fields(_.a, _.b, ...) — focus a NamedTuple per element.

.fields(_.a, _.b, ...) — focus a NamedTuple per element.

Attributes

Source
JsonTraversal.scala
def getAll(input: Json | String): Ior[Chain[JsonFailure], Vector[A]]

Read every focus. String input is parsed first; a prefix-walk miss (or non-array terminal) is Ior.Left(chain), per-element failures accumulate — elements that fail drop out of the Vector while their failures join the chain (Ior.Both).

Read every focus. String input is parsed first; a prefix-walk miss (or non-array terminal) is Ior.Left(chain), per-element failures accumulate — elements that fail drop out of the Vector while their failures join the chain (Ior.Both).

Attributes

Source
JsonTraversal.scala
inline def getAllUnsafe(input: Json | String): Vector[A]

Silent read — prefix miss yields Vector.empty; undecodable elements are dropped.

Silent read — prefix miss yields Vector.empty; undecodable elements are dropped.

Attributes

Source
JsonTraversal.scala
transparent inline def selectDynamic(inline name: String): Any

Dynamic field sugar — traversal.name lowers to traversal.field(_.name). Compile-time checked against A's case fields; codecs for the field type are summoned at the call site.

Dynamic field sugar — traversal.name lowers to traversal.field(_.name). Compile-time checked against A's case fields; codecs for the field type are summoned at the call site.

Attributes

Source
JsonTraversal.scala

Inherited methods

def modify(f: A => A): (Json | String) => Ior[Chain[JsonFailure], Json]

Decode each focus, apply f, re-encode in place. String input is parsed first; failures accumulate as Chain[JsonFailure], with the input Json preserved on the Ior.Both side.

Decode each focus, apply f, re-encode in place. String input is parsed first; failures accumulate as Chain[JsonFailure], with the input Json preserved on the Ior.Both side.

Attributes

Inherited from:
JsonOpticOps (hidden)
Source
JsonOpticOps.scala
def modifyUnsafe(f: A => A): (Json | String) => Json

Silent modify — any parse / navigation / decode failure passes the input through unchanged (an unparseable String becomes Json.Null first).

Silent modify — any parse / navigation / decode failure passes the input through unchanged (an unparseable String becomes Json.Null first).

Attributes

Inherited from:
JsonOpticOps (hidden)
Source
JsonOpticOps.scala
def place(a: A): (Json | String) => Ior[Chain[JsonFailure], Json]

Replace each focus with the encoding of a. Same parse / failure-accumulation behaviour as modify.

Replace each focus with the encoding of a. Same parse / failure-accumulation behaviour as modify.

Attributes

Inherited from:
JsonOpticOps (hidden)
Source
JsonOpticOps.scala
def placeUnsafe(a: A): (Json | String) => Json

Silent place — input pass-through on any failure.

Silent place — input pass-through on any failure.

Attributes

Inherited from:
JsonOpticOps (hidden)
Source
JsonOpticOps.scala
def transfer[C](f: C => A): (Json | String) => C => Ior[Chain[JsonFailure], Json]

place from a foreign source: replace each focus with the encoding of f(c).

place from a foreign source: replace each focus with the encoding of f(c).

Attributes

Inherited from:
JsonOpticOps (hidden)
Source
JsonOpticOps.scala
def transferUnsafe[C](f: C => A): (Json | String) => C => Json

Silent transfer — input pass-through on any failure.

Silent transfer — input pass-through on any failure.

Attributes

Inherited from:
JsonOpticOps (hidden)
Source
JsonOpticOps.scala
def transform(f: Json => Json): (Json | String) => Ior[Chain[JsonFailure], Json]

Rewrite the raw Json at each focus — no decode of the focus, so f sees (and must return) plain Json. Same parse / failure-accumulation behaviour as modify.

Rewrite the raw Json at each focus — no decode of the focus, so f sees (and must return) plain Json. Same parse / failure-accumulation behaviour as modify.

Attributes

Inherited from:
JsonOpticOps (hidden)
Source
JsonOpticOps.scala
def transformUnsafe(f: Json => Json): (Json | String) => Json

Silent transform — input pass-through on any failure.

Silent transform — input pass-through on any failure.

Attributes

Inherited from:
JsonOpticOps (hidden)
Source
JsonOpticOps.scala