Skip to content

Instantly share code, notes, and snippets.

@kevinmeredith
Created February 11, 2014 16:01
Show Gist options
  • Select an option

  • Save kevinmeredith/8937760 to your computer and use it in GitHub Desktop.

Select an option

Save kevinmeredith/8937760 to your computer and use it in GitHub Desktop.
PersonReads
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))
}
@kevinmeredith

Copy link
Copy Markdown
Author

In my SBT project I also used: (new Person(_, _)) instead of (x, y) ...

This approach is less code, so maybe better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment