foo: String, val bar: Int) implicit val encoder: Encoder[Thing] = new Encoder[Thing] { final def apply(t: Thing): Json = Json.obj( ("foo", Json.fromString(s"It's a ${t.foo}")), ("bar", Json.fromInt(t.bar * 1000)) ) } implicit val decoder: Decoder[Thing] = new Decoder[Thing] { final def apply(c: HCursor): Decoder.Result[Thing] = for { foo <- c.downField("foo").as[String] bar < c downField("bar") as[Int]