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"
}
Answer from Ori Marko on Stack Overflow
🌐
Maven Repository
mvnrepository.com › artifact › org.springframework.boot › spring-boot-starter-json
Maven Repository: org.springframework.boot » spring-boot-starter-json
1 month ago - Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can just run ... aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library logging maven ...
🌐
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

Discussions

java - Maven + Spring Boot: Found multiple occurrences of org.json.JSONObject on the class path: - Stack Overflow
You may want to drop your dependency to org.json because it is considered as non-free software. Spring Boot removed their dependency to it because of this but this sometimes results in conflicts like yours. ... @DidierL is that still the case? github.com/stleary/JSON-java/blob/master/LICENSE ... More on stackoverflow.com
🌐 stackoverflow.com
java - JSONObject ClassNotFoundException - Stack Overflow
This is the latest dependency & it don't seems to have "import org.json.JSONObject;". Could you please guide ASAP? More on stackoverflow.com
🌐 stackoverflow.com
java - Dependency org.json:json:jar is missing - Stack Overflow
I have a problem with the project I am working on. Until Tuesday everything seemed to be fine when I was building and running my project. Today I wanted to run the project and I received this error More on stackoverflow.com
🌐 stackoverflow.com
org.json JAR provisioning - Stack Overflow
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... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Maven Repository
mvnrepository.com › artifact › org.json › json
Maven Repository: org.json » json
December 24, 2025 - There are a large number of JSON packages in Java. Perhaps someday the Java community will standardize on one. Until then, choose carefully. ... aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library logging maven mobile module npm osgi persistence plugin resources rlang sdk server service spring ...
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.

🌐
Maven Central Repository
search.maven.org › org.springframework.boot › spring-boot-starter-json › 2.2.3.release
spring-boot-starter-json
<?xml version="1.0" encoding="UTF-8"?> ...pring.io</organizationUrl> </developer> </developers> <scm> <connection>scm:git:git://github.com/spring-projects/spring-boot.git</connection> <developerConnection>scm:git:ssh://git@github.com/spring-projects/spring-boot.git</developerConnection> <url>https://github.com/spring-projects/spring-boot</url> </scm> <issueManagement> <system>Github</system> <url>https://github.com/spring-projects/spring-boot/issues</url> </issueManagement> <dependencies> <dependency> ...
🌐
Maven Repository
mvnrepository.com › artifact › org.json › json › 20210307
Maven Repository: org.json » json » 20210307
March 9, 2021 - aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library logging maven mobile module npm osgi persistence plugin resources rlang sdk server service spring ...
Published   Mar 09, 2021
Version   20210307
Find elsewhere
🌐
Sourcecodeexamples
sourcecodeexamples.net › 2019 › 12 › json-maven-dependency.html
json maven dependency
December 3, 2019 - <!-- https://mvnrepository.com/artifact/org.json/json --> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20190722</version> </dependency> For more details about the proper version to use, check out the following Maven Central link.
🌐
Maven Central
central.sonatype.com › artifact › org.json › json
org.json:json - Maven Central
<dependency> <groupId>org.json...1224</version> <packaging>bundle</packaging> <name>JSON in Java</name> <description> JSON is a light-weight, language independent, data interchange format....
🌐
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 › com.github.cliftonlabs › json-simple › 2.1.2 › source code › jsonobject.java
org.json.simple.JSONObject Maven / Gradle / Ivy
org.json.simple.JSONObject maven / gradle build tool code. The class is part of the package ➦ Group: com.github.cliftonlabs ➦ Artifact: json-simple ➦ Version: 2.1.2
🌐
GitHub
github.com › spring-projects › spring-boot › issues › 9630
org.json implementation used by spring-boot-starter-test clashes with the commonly used one · Issue #9630 · spring-projects/spring-boot
June 29, 2017 - spring-boot-starter-test eventually depends on non-standard org.json implementation com.vaadin.external.google:android-json which clashes with the commonly used org.json:json. The symptom is exception java.lang.NoSuchMethodError: org.jso...
Author   xtreye
🌐
Maven Repository
mvnrepository.com › artifact › org.json
Maven Repository: org.json
JSON framework based on org.json implementation (patched for ChargeBee). ... aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library logging maven mobile module npm osgi persistence plugin resources rlang sdk server service spring sql starter testing tools ui web webapp
🌐
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
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.ssts</groupId> <artifactId>momcab1</artifactId> <name>momcab1</name> <packaging>war</packaging> <version>1.0.0-BUILD-SNAPSHOT</version> <properties> <java-version>1.7</java-version> <org.springframework-version>4.0.3.RELEASE</org.springframework-version> <org.aspectj-version>1.7.4</org.aspectj-version> <org.sl
🌐
GitHub
github.com › springdoc › springdoc-openapi-maven-plugin
GitHub - springdoc/springdoc-openapi-maven-plugin: Library for OpenAPI 3 with spring-boot · GitHub
<plugin> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-maven-plugin</artifactId> <version>last-release-version</version> <executions> <execution> <id>integration-test</id> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <apiDocsUrl>http://localhost:8080/v3/api-docs</apiDocsUrl> <outputFileName>openapi.json</outputFileName> <outputDir>home/springdoc/maven-output</outputDir> <skip>false</skip> <failOnError>true</failOnError> <headers> <header1key>header1value</header1key> <header2key>header2value</header2key> </headers> </configuration> </plugin>
Starred by 166 users
Forked by 42 users
Languages   Java
🌐
Jar-Download
jar-download.com › home › org.json › json › 20180813 › source code › jsonobject.java
org.json.JSONObject Maven / Gradle / Ivy
// This is to maintain backwards compatibility before PR406 // (https://github.com/stleary/JSON-java/pull/406/) if (Character.isLowerCase(key.charAt(0))) { return null; } if (key.length() == 1) { key = key.toLowerCase(Locale.ROOT); } else if (!Character.isUpperCase(key.charAt(1))) { key = key.substring(0, 1).toLowerCase(Locale.ROOT) + key.substring(1); } return key; } /** * Searches the class hierarchy to see if the method or it's super * implementations and interfaces has the annotation.
🌐
Baeldung
baeldung.com › home › json › introduction to json-java (org.json)
Introduction to JSON-Java (org.json)
June 20, 2025 - In this tutorial, we’ll see how to create, manipulate, and parse JSON using one of the available JSON processing libraries in Java – the JSON-Java library, also known as org.json. First, let’s add the following dependency in our pom.xml:
🌐
Maven Central
central.sonatype.com › artifact › org.springframework.boot › spring-boot-starter-json
spring-boot-starter-json - Maven Central - Sonatype
pkg:maven/org.springframework.boot/spring-boot-starter-json@Loading... ... <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-json</artifactId> <version>4.1.0-M2</version> </dependency>