org.json JAR 配置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10396176/
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-09-03 18:18:41  来源:igfitidea点击:

org.json JAR provisioning

jsonjar

提问by pilcrowpipe

I was wondering why www.json.org/anyone else doesn't provide an official JAR package of org.json for download? All queries I find of people asking where they can download the JAR results in replies to the page which just lists the source files.

我想知道为什么 www.json.org/anyone else 不提供 org.json 的官方 JAR 包供下载?我发现人们询问他们可以在哪里下载 JAR 的所有查询都会导致对仅列出源文件的页面的回复。

It seems a bit cumbersome to expect everybody to download each source file and prepare the JAR file themselves.

期望每个人都下载每个源文件并自己准备 JAR 文件似乎有点麻烦。

回答by david99world

Have you considered using Maven? for instance, if you wanted a JAR to pars JSON you could just include...

你考虑过使用Maven吗?例如,如果您想要一个 JAR 来解析 JSON,您可以只包含...

http://mvnrepository.com/artifact/org.codehaus.Hymanson/Hymanson-core-asl/1.9.6

http://mvnrepository.com/artifact/org.codehaus.Hymanson/Hymanson-core-asl/1.9.6

<dependency>
    <groupId>org.codehaus.Hymanson</groupId>
    <artifactId>Hymanson-core-asl</artifactId>
    <version>1.9.6</version>
</dependency>

in a pom.xml, this will give you the jar for JSON.

在 pom.xml 中,这将为您提供 JSON 的 jar。

Or better yet, use the org.json one...

或者更好的是,使用 org.json 一个...

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

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

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

回答by mirabilos

The implementation from json.org by Douglas Crockford is nōn-free. Luckily, a Free almost drop-in replacement exists (apparently, Google's code packaged by someone else for Maven Central):

Douglas Crockford 来自 json.org 的实现是非免费的。幸运的是,存在一个几乎免费的替代品(显然,Google 的代码是由其他人为 Maven Central 打包的):

<dependency>
    <groupId>com.vaadin.external.google</groupId>
    <artifactId>android-json</artifactId>
    <version>0.0.20131108.vaadin1</version>
</dependency>

Add this to pom.xmlinstead of using the json.org one. We had to do only one minor change to our code for this: the vaadin one can throw JSONExceptionin more places, so we had to either catch them or pass them through to the callers (extend the throws declaration).

将此添加到pom.xml而不是使用 json.org 之一。为此,我们只需要对我们的代码做一个小改动:vaadin 可以扔到JSONException更多的地方,所以我们必须抓住它们或将它们传递给调用者(扩展 throws 声明)。

回答by Ted Dunning

Beware that the json.org software has a non-open source license. This causes downstream problems in many cases.

请注意 json.org 软件具有非开源许可证。这在很多情况下会导致下游问题。

The issue is that the license is essentially the MIT license, but it adds a line that says that the software should only be used for good, not evil. This sounds fine, but if you have to get a corporate lawyer to sign off it gets nasty because there is no consensus legal definition of "evil". If you use json.org's library, you can't put your software into Debian, for instance. Your software likewise can't be a dependency for any Apache project.

问题是该许可证本质上是 MIT 许可证,但它添加了一行说明该软件只能用于善,而不是用于恶。这听起来不错,但是如果您必须让公司律师签字,那会变得令人讨厌,因为对“邪恶”没有达成共识的法律定义。例如,如果您使用 json.org 的库,则无法将您的软件放入 Debian。您的软件同样不能成为任何 Apache 项目的依赖项。

To help with this, I have adapted and packaged the android clean-room rewrite of the json.org library. The source is on github and is Apache licensed. See https://github.com/tdunning/open-json. To use this, add something like this to your pom (or equivalent):

为了解决这个问题,我改编并打包了 json.org 库的 android clean-room 重写。源代码在 github 上并且是 Apache 许可的。请参阅https://github.com/tdunning/open-json。要使用它,请在您的 pom(或等效项)中添加如下内容:

<!-- https://mvnrepository.com/artifact/com.tdunning/json -->
<dependency>
    <groupId>com.tdunning</groupId>
    <artifactId>json</artifactId>
    <version>1.3</version>
</dependency>

Ping me with pull requests or issues on github or however you like.

在 github 上向我发送拉取请求或问题,或者您喜欢的任何方式。

回答by John

Using the com.tdunnning package can lead to dependency conflicts, especially if you make your project available to others as a library. The implementation does not have 100% compatibility with org.json

使用 com.tdunnning 包可能会导致依赖冲突,尤其是当您将项目作为库提供给其他人时。该实现与 org.json 没有 100% 的兼容性

That package(com.tdunning) has been forked to https://github.com/openjson/openjsonwith the package renamed to com.github.openjson instead of org.json to prevent conflicts.

该包(com.tdunning)已被分叉到https://github.com/openjson/openjson,包重命名为 com.github.openjson 而不是 org.json 以防止冲突。

The maven dependency:

Maven 依赖:

<dependency>
    <groupId>com.github.openjson</groupId>
    <artifactId>openjson</artifactId>
    <version>1.0.10</version>
</dependency>
<dependency>
    <groupId>com.github.openjson</groupId>
    <artifactId>openjson</artifactId>
    <version>1.0.10</version>
</dependency>