I have a class which I want to be able to convert to json:
case class Page[T](items: Seq[T], pageIndex: Int, pageSize: Int, totalCount: Long)
object Page {
i
I don't think that you can have a generic writer for any type parameter. I propose following:
trait Page[T] {
val items: Seq[T]
val pageIndex: Int
val pageSize: Int
val totalCount: Long
}
case class IntPage(items: Seq[Int], pageIndex: Int, pageSize: Int, totalCount: Long) extends Page[Int]
object Page {
implicit def jsonWriter = Json.writes[IntPage]
}