Advertisement
Guest User

collab

a guest
May 5th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.97 KB | None | 0 0
  1. package models
  2.  
  3. import org.joda.time.DateTime
  4. import play.api.libs.json.{Json, Writes, JsPath, Reads}
  5. import play.api.libs.functional.syntax._
  6.  
  7.  
  8. case class Collab(id: Int, pays: String, entree: DateTime, naiss: DateTime, sexe: String, nbHeureDef: Int, nbItg: Int)
  9.  
  10. object Collab{
  11.   implicit val collabReads : Reads[Collab] = (
  12.     (JsPath \ "id").read[Int] and
  13.       (JsPath \ "pays").read[String] and
  14.       (JsPath \ "entree").read[DateTime] and
  15.       (JsPath \ "naiss").read[DateTime] and
  16.       (JsPath \ "sexe").read[String] and
  17.       (JsPath \ "nbHeureDef").read[Int] and
  18.       (JsPath \ "nbItg").read[Int]
  19.     )(Collab.apply _)
  20.  
  21.  
  22.   implicit val collabWrites = new Writes[Collab] {
  23.     def writes(collab: Collab) = Json.obj(
  24.       "id" -> collab.id,
  25.       "pays" -> collab.pays,
  26.       "entree" -> collab.entree,
  27.       "naiss" -> collab.naiss,
  28.       "sexe" -> collab.sexe,
  29.       "nbHeureDef" -> collab.nbHeureDef,
  30.       "nbItg" -> collab.nbItg
  31.     )
  32.   }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement