I am looking to provide JSON encoders for the following case class:
import io.circe.generic.extras.Configuration
final case class Hello[T](
source: String,
version: Int = 1,
data: T
)
object Hello {
implicit val configuration: Configuration = Configuration.default.withDefaults
}
I would ordinarily call deriveEncoder[A]
in the companion object, but that doesn't work here as there is no reference or Encoder
for T
available here.
The Hello
type will be provided to clients as a library, so I would like to do as much of the boilerplate as possible within this type rather than depend on client code providing the encoder and decoder. Is there an idiomatic solution to this with circe so that clients provide an encoder/decoder for T
and this gets used to derive the encoder/decoder for Hello[T]
?