通读这篇文章,我不知道如何将我的转换Some(JsValue)
为字符串。
例子:
val maybeString: Option[JsValue] = getSomeJsValue(); // returns Some(JsValue)
val str: String = maybeString match {
case Some(x) => x.as[String]
case _ => "0"
}
运行时错误:
play.api.Application$$anon$1: Execution exception[[JsResultException: JsResultException(errors:List((,List(ValidationErr
or(validate.error.expected.jsstring,WrappedArray())))))]]
at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.3]