compress irwin move report JSON

This commit is contained in:
Thibault Duplessis 2017-06-04 14:19:46 +02:00
parent 2de8c205f7
commit 4f3eaa4768

View file

@ -7,14 +7,22 @@ import play.api.libs.json._
object JSONHandlers {
import IrwinReport._
private implicit val moveReportReader = Json.reads[MoveReport]
private implicit val gameReportReader = Json.reads[GameReport]
private implicit val pvReader = Reads[Option[Int]] {
case JsNumber(n) if n.isValidInt => JsSuccess(n.toInt.some)
case _ => JsSuccess(None)
}
implicit val moveReader: Reads[MoveReport] = (
(__ \ "a").read[Int] and // activation
(__ \ "r").readNullable[Int] and // rank
(__ \ "m").read[Int] and // ambiguity
(__ \ "o").read[Int] and // odds
(__ \ "l").read[Int] // loss
)(MoveReport.apply _)
private implicit val gameReportReader = Json.reads[GameReport]
implicit val reportReader: Reads[IrwinReport] = (
(__ \ "userId").read[String] and
(__ \ "isLegit").readNullable[Boolean] and