I have following case class
case class UserId(value: String) extends MappedTo[String]
(MappedTo
is a generic id case class of slick.typesafe
)
and I declare its serializer in json4s
case object IdSerializer extends CustomSerializer[UserId](format => ( {
case JString(s) => UserId(s)
case JNull | JNothing => null
}, {
case i: UserId => JString(i.value)
case JNull | JNothing => null
}))
The problem is that I have more than 20 id fields like that, and I don't want to declare serializer for each of it. Is there a way to do it for MappedTo
so it can be applied to all of its subclass?