Created
April 30, 2015 15:27
-
-
Save gbougeard/0b7972824f95aaeaa9a1 to your computer and use it in GitHub Desktop.
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
case class GHUser( | |
login: String, | |
id: Long, | |
avatar_url: String, | |
gravatar_id: Option[String], | |
url: String, | |
html_url: String, | |
followers_url: String, | |
following_url: Option[String], | |
gists_url: Option[String], | |
starred_url: String, | |
subscriptions_url: String, | |
organizations_url: String, | |
repos_url: String, | |
events_url: Option[String], | |
received_events_url: String, | |
`type`: String, | |
site_admin: Boolean | |
) | |
case class GHPullRequestMini(project :String, | |
url: String, | |
title: String, | |
state: String, | |
user: GHUser, | |
body: String, | |
created_at: String, | |
updated_at: String, | |
closed_at: Option[String], | |
merged_at: Option[String], | |
assignee: Option[GHUser], | |
branch: String | |
) | |
implicit val GHUserJsonWrite = { | |
import play.api.data.mapping.json.Writes._ // let's no leak implicits everywhere | |
Write.gen[GHUser, JsObject] | |
} | |
implicit val GHPullRequestMiniJsonWrite = { | |
import play.api.data.mapping.json.Writes._ // let's no leak implicits everywhere | |
Write.gen[GHPullRequestMini, JsObject] | |
} | |
val pullRequests:Seq[GHPullRequestMini] = ... | |
val json = To[Seq[GHPullRequestMini], JsObject](pullRequests) | |
// => could not find implicit value for parameter w: play.api.data.mapping.WriteLike[Seq[models.GHPullRequestMini],play.api.libs.json.JsObject] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mouai en fait pour generer le
Write
il faut unJsObject
car tu as besoin duMonoid
sur ce type. Par contre pour laSeq
i tu faut uneJsValue
du coup il faut que tu type explicitementGHPullRequestMiniJsonWrite
Exemple: