简体   繁体   English

使用Scala play-json JsValue.as解析字符串时生成错误

[英]Build error using Scala play-json JsValue.as to parse string

I'm using scala play-json to parse the keys from a simple json object from a string along the lines of 我正在使用scala play-json从字符串中沿线的简单json对象解析键

'{"test": "value", "hello": "world"}' '{“ test”:“ value”,“ hello”:“ world”}'

The code where I'm doing this looks like this: 我执行此操作的代码如下所示:

val columns = Json.parse(value).as[JsObject].keys.toList

I was able to run this and get the result I wanted running the debugger in IntelliJ, so I know this code works fine. 我能够运行它并获得想要在IntelliJ中运行调试器的结果,所以我知道这段代码可以正常工作。 However, when I try to run sbt assembly on my project, I get a build error saying 但是,当我尝试在项目上运行sbt assembly时,出现构建错误提示

Validation.scala:126: bad symbolic reference to java.time encountered in class file 'DefaultReads.class'. Validation.scala:126:在类文件“ DefaultReads.class”中遇到对java.time的错误符号引用。

[error] Cannot access term time in package java. [错误]无法访问包java中的术语时间。 The current classpath may be missing a definition for java.time, or DefaultReads.class may have been compiled against a version that's incompatible with the one found on the current classpath. 当前类路径可能缺少java.time的定义,或者可能已针对与当前类路径上找到的版本不兼容的版本编译了DefaultReads.class。

[error] val values = Json.parse(value).as[JsObject].keys.toList [错误] val值= Json.parse(value).as [JsObject] .keys.toList

I'm running jdk 1.8.0_111 so I shouldn't be having the issue I've found on other SO posts trying to use the play-json library. 我正在运行jdk 1.8.0_111,所以我不应该在尝试使用play-json库的其他SO帖子上遇到这个问题。

I'm using sbt version 0.13.13, scala version 2.11.0, and (trying to use) play-json version 2.5.12 我正在使用sbt版本0.13.13,scala版本2.11.0和(尝试使用)play-json版本2.5.12

The issue was I had set the global jdk intellij and the jdk for the project, but I had recently changed my JAVA_HOME to jdk 1.7 and never changed it back. 问题是我已经为项目设置了全局jdk intellij和jdk,但是最近我将JAVA_HOME更改为jdk 1.7,但从未将其更改回。

Thanks for the responses anyways! 仍然感谢您的回复!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM