I’m trying to render some response like this
def doAjax = Action { request =>
object MyResult {
val resultCode = 0
val resultTextMessage = "sss"
}
Ok(Json(MyResult)) // It's not working anymore - not compiling in v2.0!
}
but how to map my object (MyResult) to JSON with Play 2.0?
In Play 1.0 with scala module I did successfully the following:
def dosomeaj = {
object MyResult{
val resultCode = 0
val resultTextMessage = "sss"
}
Json(MyResult) // It's working in 1.0
}
EDIT2
New Wiki link for v2.1. The old link below is not working anymore.
EDIT
We’ll all be happy to read the new Wiki entry for this point. Check this out
PREVIOUS
Here is the comment from the community about the state of Json support in play 2.0.
link to Post
They are moving from Jackson to a philosophy inspired by SJSON that offers more control on the un/marshalling, that brings facilities to manage them, w/o the overhead of Reflection (which I agree with them is a pain for performance and is fragile against Class changes…)
So here is what you can read on the post:
In the second link (SJSON), I propose you to pay special attention to the generic formatting possible by using
case classand their deconstruction method (unapply).