I have a problem with default parameters and using Play Json Read. Here is my code:
case class Test(action: String, storeResult: Option[Boolean] = Some(tru
It looks as if support for default parameters is in version 2.6.
A workaround for prior versions is to do something like the following:
object TestBuilder {
def apply(action: String, storeResult: Option[Boolean], returndata: Option[Boolean]) =
Test(
action,
Option(storeResult.getOrElse(true)),
Option(returndata.getOrElse(true))
)
}
implicit val testReads: Reads[Test] =
(
(JsPath \\ "action").read[String](minLength[String](1)) and
(JsPath \\ "store_result").readNullable[Boolean] and
(JsPath \\ "returndata").readNullable[Boolean]
)(TestBuilder.apply _)