简体   繁体   English

Play框架:从版本2.3.x迁移到2.4.1的问题

[英]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.

相关问题 Play Framework-从版本2.3.x迁移到2.4.1:如何确定JSON值是否为JsUndefined - Play Framework - migration from version 2.3.x to 2.4.1: how to determine whether a JSON value is JsUndefined 在Play Framework 2.3.x(Scala)中为案例类定义交叉属性Json验证器 - Defining cross-attribute Json Validators for a case class in Play Framework 2.3.x (Scala) 播放2.3.x框架:如何拒绝所有非application / json请求 - play 2.3.x framework: How to decline all non application/json requests 如何在Play framework 2.3.x(Scala)中将case类转换为JSON? - How to convert case class to JSON in Play framework 2.3.x (Scala)? 播放2.3.x Scala - 如何在视图上显示json数据? - Play 2.3.x Scala - How to display json data on view? Play 2.3.x中对Java8 ZonedDateTime的隐式json读写? - Implicit json Writes and Reads for Java8 ZonedDateTime in Play 2.3.x? 在grails 2.3.x中使用RestAPI JSON - Consuming a RestAPI JSON in grails 2.3.x Play Framework 2.4.1:如何从JsArray中删除元素 - Play Framework 2.4.1: How to remove an element from a JsArray 更改Grails 2.3.x域类上@Resource的结果的max属性的默认值 - Change default for max attribute on results for @Resource on domain classes for Grails 2.3.x Playframework 2.3.x:Json映射错误“此行有多个标记:找不到未应用的功能” - Playframework 2.3.x: Json mapping error “Multiple markers at this line: No unapply function found”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM