Automatic Derivation

It is also possible to derive Encoders and Decoders for many types with no boilerplate at all. circe uses shapeless to automatically derive the necessary type class instances:

import io.circe.generic.auto._, io.circe.syntax._

case class Person(name: String)
case class Greeting(salutation: String, person: Person, exclamationMarks: Int)

Greeting("Hey", Person("Chris"), 3).asJson
// res0: io.circe.Json = JObject(
//   value = object[salutation -> "Hey",person -> {
//   "name" : "Chris"
// },exclamationMarks -> 3]
// )