Created
February 5, 2014 08:33
-
-
Save ndeloof/8819372 to your computer and use it in GitHub Desktop.
play List JSON serialization
This file contains 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
No Json deserializer found for type List[models.Subscription]. Try to implement an implicit Writes or Format for this type. | |
In /Volumes/HD/Users/nicolas/Boulot/cloudbees/je-sp/app/controllers/API.scala at line 25. | |
val subscriptions: List[Subscription] = ??? | |
22 Ok( | |
23 Json.obj("account" -> account.getName, | |
24 "salesforce_id" -> account.getId, | |
25 "subscriptions" -> subscriptions, | |
26 "licenses" -> "TODO", | |
27 "credits" -> "TODO") | |
class Subscription(...) extends Writes[Subscription]{ | |
def writes(o: Subscription): JsValue = { | |
Json.obj( | |
"product" -> product, | |
"expiration" -> FastDateFormat.getInstance("dd-MM-yyyy").format(expiration)) | |
} | |
} |
You can also try if you don't want to implement your own Writer
implicit val subscriptionFormat = Json.format[Subscription]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is
class Subscription(...) extends Writes[Subscription]
?You need to provide an implicit val/object implementing Writes[Subscription].
You can put it in the companion object Subscription to have it implicitly with any instance of Subscription.