Fezziwig, named for the character from A Christmas Carol, is a library for compile time generation of Circe encoders/decoders for Scrooge-generated classes representing Thrift objects.
libraryDependencies ++= Seq(
"com.gu" %% "fezziwig" % "2.0.0"
)
To use the library, import the macros and use circe’s semiauto derivation. (Automatic derivation is no longer supported, as of v2.0.0.)
import io.circe.generic.semiauto.__
import com.gu.fezziwig.CirceScroogeMacros._
import com.gu.fezziwig.CirceScroogeWhiteboxMacros._
implicit val exampleStructEncoder: Encoder[ExampleStruct] = deriveEncoder
implicit val exampleStructDecoder: Decoder[ExampleStruct] = deriveDecoder
The generated decoders support accumulation of errors, e.g.
val result = exampleStructDecoder.accumulating(json.hcursor)