JsonCodec

zio.json.JsonCodec
See theJsonCodec companion object
final case class JsonCodec[A](encoder: JsonEncoder[A], decoder: JsonDecoder[A])

A JsonCodec[A] instance has the ability to encode values of type A into JSON, together with the ability to decode such JSON into values of type A.

Instances of this trait should satisfy round-tripping laws: that is, for every value, instances must be able to successfully encode the value into JSON, and then successfully decode the same value from such JSON.

For more information, see JsonDecoder and JsonEncoder.

{{ val intCodec: JsonCodec[Int] = JsonCodec[Int]

intCodec.encodeJson(intCodec.encodeJson(42)) == Right(42) }}

Attributes

Companion
object
Source
JsonCodec.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type

Members list

Value members

Concrete methods

final def *>[B](that: => JsonCodec[B])(implicit ev: Unit <:< A): JsonCodec[B]

Attributes

Source
JsonCodec.scala
final def <*(that: => JsonCodec[Unit]): JsonCodec[A]

Attributes

Source
JsonCodec.scala
final def <*>[B](that: => JsonCodec[B]): JsonCodec[(A, B)]

An alias for JsonCodec#zip.

An alias for JsonCodec#zip.

Attributes

Source
JsonCodec.scala
final def <+>[B](that: => JsonCodec[B]): JsonCodec[Either[A, B]]

An alias for JsonCodec#orElseEither.

An alias for JsonCodec#orElseEither.

Attributes

Source
JsonCodec.scala
final def <>(that: => JsonCodec[A]): JsonCodec[A]

An alias for JsonCodec#orElse.

An alias for JsonCodec#orElse.

Attributes

Source
JsonCodec.scala
final def decodeJson(str: CharSequence): Either[String, A]

Attributes

Source
JsonCodec.scala
final def encodeJson(a: A, indent: Option[Int]): CharSequence

Attributes

Source
JsonCodec.scala
final def orElse(that: => JsonCodec[A]): JsonCodec[A]

Attributes

Source
JsonCodec.scala
final def orElseEither[B](that: => JsonCodec[B]): JsonCodec[Either[A, B]]

Attributes

Source
JsonCodec.scala
final def transform[B](f: A => B, g: B => A): JsonCodec[B]

Attributes

Source
JsonCodec.scala
final def transformOrFail[B](f: A => Either[String, B], g: B => A): JsonCodec[B]

Attributes

Source
JsonCodec.scala
final def zip[B](that: => JsonCodec[B]): JsonCodec[(A, B)]

Attributes

Source
JsonCodec.scala
final def zipLeft(that: => JsonCodec[Unit]): JsonCodec[A]

Attributes

Source
JsonCodec.scala
final def zipRight[B](that: => JsonCodec[B])(implicit ev: Unit <:< A): JsonCodec[B]

Attributes

Source
JsonCodec.scala

Inherited methods

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
Source
Product.scala

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
Source
Product.scala