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

Optics

def apply[A](path: String)(using codec: JsonValueCodec[A]): JsoniterTraversal[A]

Build a read-write Traversal over a JSON byte buffer at the given JSONPath. 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).

Build a read-write Traversal over a JSON byte buffer at the given JSONPath. 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).

Throws IllegalArgumentException if the path string is not parseable.

Attributes

Example
import com.github.plokhotnyuk.jsoniter_scala.macros.JsonCodecMaker
given codec: JsonValueCodec[Long] = JsonCodecMaker.make
val itemsT = JsoniterTraversal[Long]("$.cart.items[*]")
val bytes: Array[Byte] = ...
itemsT.foldMap(identity[Long])(bytes)  // Long — sum of all items, zero AST allocation
itemsT.modify(_ * 10)(bytes)           // Array[Byte] — every item 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