我正在尝试做出这样的回应
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!
}
但是如何使用 Play 2.0 将我的对象(MyResult)映射到 JSON?在使用 scala 模块的 Play 1.0 中,我成功地完成了以下操作:
def dosomeaj = {
object MyResult{
val resultCode = 0
val resultTextMessage = "sss"
}
Json(MyResult) // It's working in 1.0
}