guardian / fezziwig   2.0.1

Apache License 2.0 GitHub

Fezziwig is a library for compile time generation of Circe encoders/decoders for Scrooge-generated classes representing Thrift objects.

Scala versions: 2.13 2.12

Fezziwig

fezziwig Scala version support Release

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.

Installation

libraryDependencies ++= Seq(
  "com.gu" %% "fezziwig" % "2.0.0"
)

Usage

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)