Created
February 11, 2014 16:01
-
-
Save kevinmeredith/8937760 to your computer and use it in GitHub Desktop.
PersonReads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package common | |
| import play.api.libs.json._ | |
| import play.api.libs.functional.syntax._ | |
| object PersonUtil { | |
| implicit val PersonReads: Reads[Person] = ( | |
| (JsPath \ "name").read[String] and | |
| (JsPath \ "age").read[Int] | |
| )((x,y) => new Person(x,y)) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my SBT project I also used:
(new Person(_, _))instead of(x, y) ...This approach is less code, so maybe better.