如何在 Java 7 中使用 org.json Java 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27352672/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 04:12:51  来源:igfitidea点击:

How to use the org.json Java library with Java 7

javajsonorg.json

提问by Luke

I need some simple JSON parsing in my application and the Douglas Crockford libraryseems exactly what I need.

我需要在我的应用程序中进行一些简单的 JSON 解析,而Douglas Crockford 库似乎正是我所需要的。

However, I seem to be running into a problem. I'm getting the following error:

但是,我似乎遇到了问题。我收到以下错误:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/json/JSONObject : Unsupported major.minor version 52.0

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/json/JSONObject : Unsupported major.minor version 52.0

I Googled around a bit and I get the impression that this is due to some version incompatibility. I've tried changing Java versions but it doesn't seem to help. I'm using Java 7 and Java 7 features in my program and ultimately I want to use Java 7.

我用谷歌搜索了一下,我觉得这是由于某些版本不兼容造成的。我试过更改 Java 版本,但似乎没有帮助。我在我的程序中使用 Java 7 和 Java 7 功能,最终我想使用 Java 7。

How can I resolve this issue?

我该如何解决这个问题?

PS: I looked at Hymanson and GSON and definitely don't want to use either so please don't suggest as an alternative.

PS:我看过 Hymanson 和 GSON 并且绝对不想使用它们,所以请不要建议作为替代。

采纳答案by David ten Hove

Have you tried using an older version of the package?

您是否尝试过使用旧版本的软件包?

Try: http://mvnrepository.com/artifact/org.json/json/20140107

试试:http: //mvnrepository.com/artifact/org.json/json/20140107

回答by malajisi

Since your are using JDK1.7, change to the older version will work!

由于您使用的是 JDK1.7,因此更改为旧版本即可!

<groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20140107</version>
</dependency>