[英]Play Framework: Problems migrating from version 2.3.x to 2.4.1
I'm migrating my Play application from version 2.3.8 to version 2.4.1... and I'm encountering some problems with JSON. 我正在将Play应用程序从2.3.8版迁移到2.4.1版...,并且遇到JSON问题。
The main issue is that now obj \\ key
returns a JsLookupResult
and statements like Json.arr(obj \\ key, 1)
fail because Json.arr
expects a JsValueWrapper
. 主要问题在于,现在
obj \\ key
返回一个JsLookupResult
并且诸如Json.arr(obj \\ key, 1)
类的语句失败,因为Json.arr
需要一个JsValueWrapper
。
How do I fix this issue? 如何解决此问题?
If you are certain that \\
will not fail, you can just call .get
on it, as you would an Option
. 如果确定
\\
不会失败,则可以像调用Option
一样调用.get
。
Json.arr( (obj \\ key).get, 1)
Needless to say, there are other operands like getOrElse
that can provide a default value in case obj
has no key
. 不用说,在
obj
没有key
情况下,还有其他操作数(例如getOrElse
可以提供默认值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.