Attributes
- Companion
- class
- Source
- JsoniterPrism.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
JsoniterPrism.type
Members list
Grouped members
Optics
Root-level Prism from a JSON byte buffer to a native type A — a Prism[Array[Byte], A]: to decodes the WHOLE document via the codec (Miss when it doesn't decode as A), from / JsoniterPrism.reverseGet encode via writeToArray. At the root the full-cover Prism laws hold (up to canonical re-encoding). Drill from here with .field: JsoniterPrism[Person].field(_.age).
Root-level Prism from a JSON byte buffer to a native type A — a Prism[Array[Byte], A]: to decodes the WHOLE document via the codec (Miss when it doesn't decode as A), from / JsoniterPrism.reverseGet encode via writeToArray. At the root the full-cover Prism laws hold (up to canonical re-encoding). Drill from here with .field: JsoniterPrism[Person].field(_.age).
Attributes
- Source
- JsoniterPrism.scala
The root prism, reading its document '''in place''' — JsoniterPrism[A].inPlace, a Prism[JsonSlice, A] to drill from: JsoniterPrism.inPlace[Issue].field(_.detail).raw.
The root prism, reading its document '''in place''' — JsoniterPrism[A].inPlace, a Prism[JsonSlice, A] to drill from: JsoniterPrism.inPlace[Issue].field(_.detail).raw.
'''No copy is made''': the optic reads, and with .raw focuses, the caller's array where it lies. Don't mutate the array while the slice or anything read from it is in use; a slice, and any slice focus, keeps the whole underlying array reachable (call JsonSlice.toArray for anything kept long-term); writes never mutate the source, but return a slice over a fresh array. See JsoniterInPlacePrism.
Attributes
- Source
- JsoniterPrism.scala
Constructors
Build a read-write Prism over a JSON byte buffer at the given JSONPath — the ONLY string-path constructor, and it keeps the failure in the type. An unparseable path, or one carrying a [*] wildcard (a JsoniterTraversal shape), comes back as Left(message): a path is DATA (a config value, a CLI argument, a registry lookup), so there is no throwing twin to reach for. Path syntax: $, dotted field names ($.foo.bar), array indices ($[0]). See PathParser for the full grammar; apply is the path-free root constructor.
Build a read-write Prism over a JSON byte buffer at the given JSONPath — the ONLY string-path constructor, and it keeps the failure in the type. An unparseable path, or one carrying a [*] wildcard (a JsoniterTraversal shape), comes back as Left(message): a path is DATA (a config value, a CLI argument, a registry lookup), so there is no throwing twin to reach for. Path syntax: $, dotted field names ($.foo.bar), array indices ($[0]). See PathParser for the full grammar; apply is the path-free root constructor.
Attributes
- Example
-
import com.github.plokhotnyuk.jsoniter_scala.macros.JsonCodecMaker given codec: JsonValueCodec[Long] = JsonCodecMaker.make val idP: Either[String, JsoniterPrism[Long]] = JsoniterPrism.fromPath[Long]("$.payload.user.id") val bytes: Array[Byte] = ... idP.map(_.foldMap(identity)(bytes)) // Either[String, Long], no AST allocation - Source
- JsoniterPrism.scala