JsoniterTraversal

dev.constructive.eo.jsoniter.JsoniterTraversal
See theJsoniterTraversal companion class

Attributes

Companion
class
Source
JsoniterTraversal.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Grouped members

Constructors

def fromPath[A](path: String)(using codec: JsonValueCodec[A]): Either[String, JsoniterTraversal[A]]

Build a read-write Traversal over a JSON byte buffer at the given JSONPath — the ONLY string-path constructor, and it keeps the failure in the type. The path MAY contain [*] wildcard steps (without them, this collapses to a single-or-zero-focus Traversal that still uses the MultiFocus[PSVec] carrier — fine, just narrower). An unparseable path comes back as Left(message): a path is DATA, so there is no throwing twin to reach for.

Build a read-write Traversal over a JSON byte buffer at the given JSONPath — the ONLY string-path constructor, and it keeps the failure in the type. The path MAY contain [*] wildcard steps (without them, this collapses to a single-or-zero-focus Traversal that still uses the MultiFocus[PSVec] carrier — fine, just narrower). An unparseable path comes back as Left(message): a path is DATA, so there is no throwing twin to reach for.

Attributes

Example
import com.github.plokhotnyuk.jsoniter_scala.macros.JsonCodecMaker
given codec: JsonValueCodec[Long] = JsonCodecMaker.make
val itemsT: Either[String, JsoniterTraversal[Long]] =
 JsoniterTraversal.fromPath[Long]("$.cart.items[*]")
val bytes: Array[Byte] = ...
itemsT.map(_.foldMap(identity[Long])(bytes))  // Either[String, Long], zero AST allocation
itemsT.map(_.modify(_ * 10)(bytes))           // Either[String, Array[Byte]], spliced in place
Source
JsoniterTraversal.scala

Extensions

Extensions

extension [A](o: JsoniterTraversal[A])
transparent inline def field[B](inline selector: A => B)(using codecB: JsonValueCodec[B]): JsoniterTraversal[B]

.field(_.x) — drill every focus into a field, compile-time checked against A.

.field(_.x) — drill every focus into a field, compile-time checked against A.

Attributes

Source
JsoniterTraversal.scala
extension [A](o: JsoniterTraversal[A])
transparent inline def at(i: Int): Any

.at(i) — drill every focus into the i-th element of a nested array.

.at(i) — drill every focus into the i-th element of a nested array.

Attributes

Source
JsoniterTraversal.scala