Skip to content

Instantly share code, notes, and snippets.

@fayimora
Last active August 29, 2015 14:16
Show Gist options
  • Save fayimora/830fd69b9bf97e91200a to your computer and use it in GitHub Desktop.
Save fayimora/830fd69b9bf97e91200a to your computer and use it in GitHub Desktop.
implicit val userWrites: Writes[User] = (
(__ \ "lastVisit").write[Timestamp] and
(__ \ "handle").write[String] and
(__ \ "firstName").write[String] and
(__ \ "lastName").write[String] and
(__ \ "email").write[String] and
(__ \ "rating").write[Int] and
(__ \ "location").write[String] and
(__ \ "shirtSize").write[String] and
(__ \ "id").writeNullable[Long] and
(__ \ "createdAt").writeNullable[Timestamp] and
(__ \ "updatedAt").writeNullable[Timestamp]
)(unlift(User.unapply))
implicit val userReads: Reads[User] = (
(__ \ "lastVisit").read[Timestamp] and
(__ \ "handle").read[String] and
(__ \ "firstName").read[String] and
(__ \ "lastName").read[String] and
(__ \ "email").read[String] and
(__ \ "rating").read[Int] and
(__ \ "location").read[String] and
(__ \ "shirtSize").read[String] and
(__ \ "id").readNullable[Long] and
(__ \ "createdAt").readNullable[Timestamp] and
(__ \ "updatedAt").readNullable[Timestamp]
)(User.apply _)
implicit val userFormat: Format[User] = Format(userReads, userWrites)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment