Add json jar to your classpath

or use java -classpath json.jar ClassName

Or add this to your maven pom.xml depedencies:

<dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20090211</version>
</dependency>
Answer from Alya'a Gamal on Stack Overflow
🌐
Maven Repository
mvnrepository.com › artifact › org.json › json
Maven Repository: org.json » json
December 24, 2025 - JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL.
Discussions

android studio cannot resolve import org.json.JSONObject - Stack Overflow
I used libgdx to build my project and I am having issues using the JSONObject class. When I add import org.json.JSONObject, it says it cannot resolve. How do I add that library to my project? Her... More on stackoverflow.com
🌐 stackoverflow.com
The curious case of JSON-Java (org.json) and Maven's dependency "hell"
The dependency tree by default exclude duplicates. You can do "mvn dependency:tree -Dverbose=true -DoutputFile=./tree.txt" and look at all inclusions of the specific library. But dependency exclusion is not the best way for your case. It is better to define your desired version within the "" section. You can verify the result by using a verbose output of the dependency:tree goal. More on reddit.com
🌐 r/java
30
25
July 19, 2025
java - Gradle build - not able to import org.json - Stack Overflow
How would that be done for org.json? 2022-10-30T12:05:44.38Z+00:00 ... Make sure your dependency configuration is set correct in your build.gradle, especially important when running plugins like a test framework. For example, I wanted to use JsonObject in a Gatling test. More on stackoverflow.com
🌐 stackoverflow.com
December 3, 2019
Import org.json:json as gradle dependency
Hi, I couldn’t expect this would become as difficult. I am trying to import org.json:json to be used inside my beans. Have tried many things in my build.gradle file, among others: compileClasspath( group: ‘org.json’, name: ‘json’, version: ‘20201115’ ) and implementation ... More on forum.jmix.io
🌐 forum.jmix.io
0
0
December 27, 2021
🌐
Maven Central
central.sonatype.com › artifact › org.json › json
org.json:json - Maven Central
See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL. This is a reference implementation. There are a large number of JSON packages in Java.
🌐
Reddit
reddit.com › r/java › the curious case of json-java (org.json) and maven's dependency "hell"
r/java on Reddit: The curious case of JSON-Java (org.json) and Maven's dependency "hell"
July 19, 2025 -

Hi. I have a recurring maven(?) issue that I hope is not unique to me and has been solved by someone somewhere.

As JSON parser, I use JSON-Java (the one with package org.json), instead of more famous ones, as the DX and API feel more fit for most/all my projects.

However, from time to time, I reach a very dreadful situation, where the "version" of the JSON-Java library that is available to my code is "not" the one that I have declared in my pom.xml file. In once case, the copyright notice in the source that I could see by clicking the class name in VSCode was from 2010, with the painful difference to the modern version that all parsing methods threw checked exceptions. In another instance, the JSONArray class did not implement Iterable/Iterator where in modern versions it does.

This is likely a maven transitive dependency issue, but the reason it is so visible for this particular library, is because either many libraries already have their own dependency on it, or that it's interface has evolved quite significantly along the way. Likely both.

The solution "in the book" for this is apparently to do "mvn dependency:tree" and exclude JSON-Java explicitly from other dependencies that depend on it. But it doesn't work for me! In my dependency three, only the recent version that is in my own pom file is shown, whereas in code/IDE (VSCode + IntelliJ), I can only use the old version. My deployment involves building a fat Jar, so it happens there too.

Am I doing something wrong? Is there a proven way to make only a certain version of a dependency available to my code, regardless of other versions that may be present deeper in the class path? Does the order of dependencies in pom file matter? and how can I strictly control the versions of dependencies that appear in my fat jar, in case it is possible at all?

Many thanks

🌐
Jar-Download
jar-download.com › home › org.json
Download org.json JAR files with all dependencies
Download org.json JAR files ✓ With dependencies ✓ Documentation ✓ Source code
🌐
TutorialsPoint
tutorialspoint.com › org_json › org_json_quick_guide.htm
Org.Json - Quick Guide
toString(JSONObject) − Converts a JSONObject to cookie text. package com.tutorialspoint; import org.json.Cookie; import org.json.JSONObject; public class JsonDemo { public static void main(String[] args) { String cookie = "username = Mark Den; expires = Thu, 15 Jun 2026 12:00:00 UTC; path = /"; //Case 1: Converts Cookie String to JSONObject JSONObject jsonObject = Cookie.toJSONObject(cookie); System.out.println(jsonObject); } }
Find elsewhere
🌐
Jmix
forum.jmix.io › support
Import org.json:json as gradle dependency - Support - Jmix
December 27, 2021 - Hi, I couldn’t expect this would become as difficult. I am trying to import org.json:json to be used inside my beans. Have tried many things in my build.gradle file, among others: compileClasspath( group: ‘org.json’, name: ‘json’, version: ‘20201115’ ) and implementation ...
Top answer
1 of 6
198

Add under

 <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>

The following exclusion:

 <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>com.vaadin.external.google</groupId>
            <artifactId>android-json</artifactId>
        </exclusion>
    </exclusions>

Similarly, for Gradle projects:

testCompile("org.springframework.boot:spring-boot-starter-test") {
    exclude group: "com.vaadin.external.google", module:"android-json"
}
2 of 6
47

Background: org.json works great, but has a license clause that some people don't like ("The Software shall be used for Good, not Evil."). So Vaadin wanted to use the library, but couldn't be sure they wouldn't use it for evil someday. Instead, they re-implemented the interface, published android-json and used it as a drop in replacement for org.json. Others began to use android-json as well so that they too would not be bound by the requirement of not using their software for evil.

This is a fine solution, except that when the two libraries are on the classpath, they collide.

Solution: If you get this error from conflicting transitive dependencies, then your best bet is to exclude either Vaadin's android-json library (brought in by Spring), or exclude the org.json library (brought in by another dependency). Vaadin's version is meant to be an identical implementation, but there are subtle differences.

If you're using org.json in your code and it is conflicting with Spring's Vaadin dependency, then I would recommend trying open-json. It's a port of Vaadin's re-implementation of org.json, but they changed the packages so you won't have any conflicts with org.json:json or com.vaadin.external.google:android-json

https://github.com/openjson/openjson

Add gradle dependency:

    implementation('com.github.openjson:openjson:1.0.12')

Or in Maven:

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

Then update any imports that were being used by org.json classes.

🌐
Stack Overflow
stackoverflow.com › questions › 42969716 › how-to-import-org-json-in-maven-using-dependency
java - How to import org.json in maven using dependency - Stack Overflow
I even tried using json-simple-1.1.1 dependency and json-simple-1.1 dependency and json-20140107 dependency. Error is still the same. So I don't know what is going on. So anyone help me to get the right JSON dependency in pom.xml · Finally I should import these · import org.json.JSONException; import org.json.JSONObject; java ·
🌐
Maven Central Repository
search.maven.org › org.json › json › 20180813
Maven Central Repository Search
There is a large number of JSON packages in Java. Perhaps someday the Java community will standardize on one. Until then, choose carefully. The license includes this restriction: "The software shall be used for good, not evil." If your conscience cannot live with that, then choose a different package. ... <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20180813</version> </dependency>
🌐
Jar-Download
jar-download.com › home › org.json › json › 20180813 › source code › jsonobject.java
org.json.JSONObject Maven / Gradle / Ivy
This is the most * commonly used JSONObject constructor. * * @param source * A string beginning with { (left * brace) and ending with } * (right brace). * @exception JSONException * If there is a syntax error in the source string or a * duplicated key. */ public JSONObject(String source) throws JSONException { this(new JSONTokener(source)); } /** * Construct a JSONObject from a ResourceBundle.
🌐
Stleary
stleary.github.io › JSON-java › index.html
Generated Documentation (Untitled)
JavaScript is disabled on your browser · Frame Alert · This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to Non-frame version
🌐
Maven Repository
mvnrepository.com › artifact › org.json › json › 20090211
Maven Repository: org.json » json » 20090211
JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL.
🌐
Baeldung
baeldung.com › home › json › introduction to json-java (org.json)
Introduction to JSON-Java (org.json)
June 20, 2025 - However, let’s not include the dependency explicitly when using the Android SDK, since it already includes the package. We use classes from the JSON-Java library to parse and manipulate JSON in Java. We also know this library as org.json.
🌐
Java2s
java2s.com › Open-Source › Maven_Repository › JSON › org.json › org_json_chargebee_1_0.htm
Maven Repository - POM file for JSON org.json chargebee-1.0 chargebee-1.0
<dependency> <groupId>org.json</groupId> <artifactId>org.json</artifactId> <version>chargebee-1.0</version> </dependency>
🌐
GitHub
github.com › stleary › JSON-java
GitHub - stleary/JSON-java: A reference implementation of a JSON package in Java. · GitHub
June 17, 2024 - import org.json.JSONObject; public class Test { public static void main(String args[]){ JSONObject jo = new JSONObject("{ \"abc\" : \"def\" }"); System.out.println(jo); } } Execute the Test file · java -cp .;json-java.jar Test (Windows) java -cp .:json-java.jar Test (Unix Systems) Expected output ·
Starred by 4.7K users
Forked by 2.6K users
Languages   Java
🌐
Jar-download
jar-download.com › maven-repository-class-search.php
Download dependencies for java class org.json.JSONObject
August 13, 2018 - Here you can download the dependencies for the java class org.json.JSONObject. Use this engine to looking through the maven repository.