使用 lift-json 和 play 框架解析/提取 json 对象时出现问题
我想将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我从 lift-json 切换到 https://github.com/codahale/jerkson ,问题解决了。
I switched from lift-json to https://github.com/codahale/jerkson , problem resolved.
您应该查看关于此问题的另一个讨论,它似乎有解释: )
You should look another discussion about this problem, it seems to be explained :)