final case class JsonCodec[A](encoder: JsonEncoder[A], decoder: JsonDecoder[A]) extends Product with Serializable
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) }}
- Self Type
- JsonCodec[A]
Linear Supertypes
Ordering
- Alphabetic
- By Inheritance
Inherited
- JsonCodec
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- Protected
Instance Constructors
- new JsonCodec(encoder: JsonEncoder[A], decoder: JsonDecoder[A])
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- 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.
- final def <+>[B](that: => JsonCodec[B]): JsonCodec[Either[A, B]]
An alias for JsonCodec#orElseEither.
- final def <>(that: => JsonCodec[A]): JsonCodec[A]
An alias for JsonCodec#orElse.
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def decodeJson(str: CharSequence): Either[String, A]
- val decoder: JsonDecoder[A]
- final def encodeJson(a: A, indent: Option[Int]): CharSequence
- val encoder: JsonEncoder[A]
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def orElse(that: => JsonCodec[A]): JsonCodec[A]
- final def orElseEither[B](that: => JsonCodec[B]): JsonCodec[Either[A, B]]
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- 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 wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- 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]