Builds Circe codecs out of JSON schema definitions.

API documentation

The JsonSchemas interpreter fixes the JsonSchema[A] to a type that provides both an io.circe.Encoder[A] and an io.circe.Decoder[A].

Given the following type definition:

sourcesealed trait Shape
case class Circle(radius: Double) extends Shape
case class Rectangle(width: Double, height: Double) extends Shape

Assuming that there is an implicit JsonSchema[Shape] definition, we can encode a Shape into JSON and decode it using the usual circe operations:

sourceimport JsonSchema._
val shape: Shape = Circle(42)
val shapeJson: Json = shape.asJson
val maybeShape: Either[circe.Error, Shape] =[Shape]