0

zio-json is unable to derive an encoder (using DeriveJsonEncoder.gen) for a case class with the @newtype annotation.

I'd rather not write even simple custom encoders for the hundreds of such classes we have. Is there any way, perhaps with some implicit conversion (which can be done with circe), to allow use of automatic derivation?

Dmytro Mitin
  • 48,194
  • 3
  • 28
  • 66
  • Generic derivation works for ADT (sealed trait + case classes). `@newtype` case class is not actually a case class. https://llcampos.wordpress.com/2020/09/06/scala-using-circe-and-newtype-to-decode-json-with-a-field-with-variable-type/ https://newtypes.monix.io/docs/circe.html You can define macro annotation generating necessary implicits – Dmytro Mitin Mar 08 '23 at 01:57

0 Answers0