With Scala 2.11, we are allowed to have more then 22 fields in a case class right??
case class SomeResponse(
var composi
To make the example above compile, I had to make the type explicit:
import play.api.libs.json._
import play.api.libs.functional.syntax._
// Let's pretend this is huge:
case class Huge(a: Int, b: String, c: Boolean, d: List[Int])
object Huge {
val fields1to2: Reads[(Int, String)] = (
(__ \ "a").read[Int] and
(__ \ "b").read[String]
).tupled
val fields3to4: Reads[(Boolean, List[Int])] = (
(__ \ "c").read[Boolean] and
(__ \ "d").read[List[Int]]
).tupled
val f: ((Int, String), (Boolean, List[Int])) => Huge = {
case ((a, b), (c, d)) => Huge(a, b, c, d)
}
implicit val hugeCaseClassReads: Reads[Huge] = (
fields1to2 and fields3to4
) { f }
}