出现此错误时正在关注 Play Frameworks 的 Scala Json api Docs:
读取的值不是 play.api.libs.json.JsValue 的成员
我的进口是:
import play.api.libs.json._ // JSON library
import play.api.libs.json.Reads._ //custom validation helpers
import play.api.libs.functional.syntax._ // Combinator syntax
和方法抛出错误是:
def callSearchRoleRowInRoleService = Action(parse.json) {
implicit request =>
var rolejson = request.body
val roleId = (rolejson \ "roleId").read[Int]
val shortDescription : Reads[String]= (rolejson \ "shortDescription").read[String]
val description = (rolejson \ "description").read[String]
val activationDate = (rolejson \ "activationDate").read[java.sql.Date]
val deactivationDate = (rolejson \ "deactivationDate").read[java.sql.Date]
}
无需读取方法即可正常工作