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