Applying conversion to play framework json element before applying to class
问题 I have a class as so case class Token( creationDate: Date, expires: Option[Date] ) { def toJson(): String = Json.stringify(Json.toJson(this)) } object Token { def fromJson(json: String): Token = Json.parse(json).as[Token] implicit val tokenReads: Reads[Token] = ( (JsPath \ "creation_date").read[Date] and (JsPath \ "expires").readNullable[Date] ) (Token.apply _) implicit val tokenWrites: Writes[Token] = ( (JsPath \ "creation_date").write[Date] and (JsPath \ "expires").writeNullable[Date] )