Skip to content

Instantly share code, notes, and snippets.

@hoangong
Last active December 31, 2018 11:10
Show Gist options
  • Save hoangong/a1b05aae660bdd734074 to your computer and use it in GitHub Desktop.
Save hoangong/a1b05aae660bdd734074 to your computer and use it in GitHub Desktop.
Play2 Json object serialization #play #scala #serialisation
val accessTokenReads = (
(__ \ "token").read[String] and
(__ \ "createdDate").read[LocalDateTime] and
(__ \ "expiredDate").read[LocalDateTime] and
(__ \ "expired").read[Boolean]
) (AccessToken.apply _)
val accessTokenWrites = (
(__ \ "token").write[String] and
(__ \ "createdDate").write[LocalDateTime] and
(__ \ "expiredDate").write[LocalDateTime] and
(__ \ "expired").write[Boolean]
) (unlift(AccessToken.unapply))
implicit val accessTokenFormat: Format[AccessToken] = Format(accessTokenReads, accessTokenWrites)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment