JsonCodec

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) }}

Companion
object
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

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

An alias for JsonCodec#zip.

An alias for JsonCodec#zip.

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

An alias for JsonCodec#orElseEither.

An alias for JsonCodec#orElseEither.

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

An alias for JsonCodec#orElse.

An alias for JsonCodec#orElse.

final
def decodeJson(str: CharSequence): Either[String, A]
final
def encodeJson(a: A, indent: Option[Int]): CharSequence
final
def orElse(that: => JsonCodec[A]): JsonCodec[A]
final
def orElseEither[B](that: => JsonCodec[B]): JsonCodec[Either[A, B]]
final
def transform[B](f: A => B, g: B => A): JsonCodec[B]
final
def transformOrFail[B](f: A => Either[String, B], g: B => A): JsonCodec[B]
final
def zip[B](that: => JsonCodec[B]): JsonCodec[(A, B)]
final
def zipLeft(that: => JsonCodec[Unit]): JsonCodec[A]
final
def zipRight[B](that: => JsonCodec[B])(implicit ev: Unit <:< A): JsonCodec[B]

Inherited methods

def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product