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._
// import io.circe.generic.auto._
// import io.circe.syntax._

case class Person(name: String)
// defined class Person

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

Greeting("Hey", Person("Chris"), 3).asJson
// res0: io.circe.Json =
// {
//   "salutation" : "Hey",
//   "person" : {
//     "name" : "Chris"
//   },
//   "exclamationMarks" : 3
// }