【问题标题】:Problem using lift-json and play framework to parse/extract json objects使用 lift-json 和 play 框架解析/提取 json 对象的问题
【发布时间】:2011-06-13 02:52:59
【问题描述】:

我想使用带有 Play 框架的 Lift-JSON (v2.2) 将 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 对象的经验。

【问题讨论】:

  • 为什么不使用基于 GSon 的播放功能呢?

标签: json scala playframework lift


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    你应该看看another discussion about this problem,好像有解释:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-23
      • 2018-11-02
      相关资源
      最近更新 更多