argonaut-shapeless icon indicating copy to clipboard operation
argonaut-shapeless copied to clipboard

Add @Wrapper annotation

Open alexarchambault opened this issue 9 years ago • 1 comments

To annotate case classes having a single field, like

@Wrapper case class Something(underlying: Underlying)

whose JSON representation is the one of the field.

Would avoid to write boilerplate like

case class Something(underlying: String)
object Something {
  implicit val decode = DecodeJson.of[Underlying].map(Something(_))
  implicit val encode = EncodeJson.of[Underlying].contramap[Something](_.underlying)
}

for simply

@Wrapper case class Something(underlying: Underlying)

alexarchambault avatar Nov 25 '15 11:11 alexarchambault

Maybe as a macro?

tylerjharden avatar Mar 16 '16 09:03 tylerjharden