Sunday, 18 August 2013

toJson in PlayfFramework2 for list of objects

toJson in PlayfFramework2 for list of objects

I've read this answer about how simple it is..
But if if I have list of Objects but not just strings:
case class Article(
title:String,
description:String,
examples: Example* // list of Example objects
)
There is Example case class:
case class Example(meaning:String, proofs:String*)
Then how I could transform my Article to json string?
If I use:
def article(word:String) = Action {
implicit val articleFormat = Json.format[Article]
val article = Article.article(word)
Ok( Json.format(article) )
}
I got an error: No unapply function found
When I try to write my unapply method, I got different error about apply..
Don't want to spoil.. Do you have an answer or at least a suggestion?

No comments:

Post a Comment