I am wondering if there is a way to ensure that the companion object has the implicit Json formatter of the class it is accompanying:
trait Entity { val id: Int } case class Foo(id: Int) extends Entity object Foo { implicit val jsonFormatter = Json.format[Foo] } For example:
trait DAO[A <: Entity] { def get[A](id: Int) = { val docs: JsValue = ??? Json.fromJson[A](docs) } } In this case, when it tries to transform the json to the case class, it will not found the implicit transformer. Any ideas to solve this?