使用 lift-json 和 play 框架解析/提取 json 对象时出现问题

发布于 2024-10-13 08:39:01 字数 1246 浏览 5 评论 0原文

我想将 Lift-JSON (v2.2) 与 Play 框架结合使用,将 JSON 文件解析为 Scala 案例类。我正在使用 scala 2.8.1 并使用 scala 插件 v0.8 播放 1.1。首先,我从 https://github 复制了代码.com/lift/lift/tree/master/framework/lift-base/lift-json/ 用于将值提取到类中(Person 类,“提取值”部分)。当我浏览到 localhost 查看结果时,我接收

play.exceptions.JavaExecutionException: Parsed JSON values do not match with class constructor
args=
arg types=
constructor=public controllers.Person(java.lang.String,controllers.Address,scala.collection.immutable.List)
 at play.mvc.ActionInvoker.invoke(ActionInvoker.java:285)
 at Invocation.HTTP Request(Play!)
Caused by: net.liftweb.json.MappingException: Parsed JSON values do not match with class constructor
args=
arg types=
constructor=public controllers.Person(java.lang.String,controllers.Address,scala.collection.immutable.List)
 at net.liftweb.json.Meta$.fail(Meta.scala:128)
...

我想 Play 以某种方式在 REPL 模式下运行 scala 命令(这里讨论的问题:http://caffiendfrog.blogspot.com/2010/11/scala-json-lift-web-trouble-with.html )我很欣赏您使用 play 和 lift-json 的经验。解析/提取 json 对象。

I would like to use Lift-JSON (v2.2) with Play framework to parse a JSON file into Scala case classes. I am using scala 2.8.1 and play 1.1 with scala pluging v0.8. To start I copied the code from https://github.com/lift/lift/tree/master/framework/lift-base/lift-json/ for extracting value into classes (Person class, section "Extracting values". When I browse to localhost to see the results I receive

play.exceptions.JavaExecutionException: Parsed JSON values do not match with class constructor
args=
arg types=
constructor=public controllers.Person(java.lang.String,controllers.Address,scala.collection.immutable.List)
 at play.mvc.ActionInvoker.invoke(ActionInvoker.java:285)
 at Invocation.HTTP Request(Play!)
Caused by: net.liftweb.json.MappingException: Parsed JSON values do not match with class constructor
args=
arg types=
constructor=public controllers.Person(java.lang.String,controllers.Address,scala.collection.immutable.List)
 at net.liftweb.json.Meta$.fail(Meta.scala:128)
...

I suppose Play somehow runs scala commands in REPL mode ( the problem discussed here: http://caffiendfrog.blogspot.com/2010/11/scala-json-lift-web-trouble-with.html ). I appreciate your experience with using play and lift-json to parse/extract json objects.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

oО清风挽发oО 2024-10-20 08:39:01

我从 lift-json 切换到 https://github.com/codahale/jerkson ,问题解决了。

I switched from lift-json to https://github.com/codahale/jerkson , problem resolved.

毁我热情 2024-10-20 08:39:01

您应该查看关于此问题的另一个讨论,它似乎有解释: )

You should look another discussion about this problem, it seems to be explained :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文