It looks like You have more than one org.json:json dependency on your classpath.

Looking at it:
org.springframework.boot:spring-boot-starter-test depends on
com.jayway.jsonpath:json-pathwhich in turn brings
org.json:json which is much older than your version (v. 20140107)

You could try excluding this transitive dependency from spring-boot-starter-test:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </exclusion>
    </exclusions>
</dependency>

... but it's possible that there is something within json-path which depends on something from the older json library, which is no longer in the newer version, so proceed with caution and test everything thoroughly.

There is also a chance that something else brings org.json:json.

To verify, please run mvn dependency:tree and search in the produced output for org.json:json.

Answer from diginoise 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 - org.springframework.boot · Description · Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can just run · Links · Maven Plugins · Testing · Android Packages · Language Runtime · JVM Languages · Logging Frameworks · JSON Libraries · Java Specifications · Core Utilities · Mocking · Annotation Libraries · Web Assets · HTTP Clients · Logging Bridges · Dependency Injection ·
Discussions

jackson2 - Use org.json with Spring Boot - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I am using Spring Boot framework and trying to create a structure where the developer can only return org.json.JSONObject instance. More on stackoverflow.com
🌐 stackoverflow.com
org.json implementation used by spring-boot-starter-test clashes with the commonly used one
It is not possible to accept this and use com.vaadin.external.google:android-json implementation in a project because it has different interface and moreover lacks XML convertion functionality. Also, Spring Boot is not an Android framework to have such dependency. More on github.com
🌐 github.com
8
June 29, 2017
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
Found multiple occurrences of org.json.JSONObject on the class path
Spring cloud function comes with a org.json.JSONObject.class that is different than the one packaged with spring boot starter test. This creates the following warning when starting the application ... More on github.com
🌐 github.com
8
June 28, 2024
🌐
GitHub
github.com › spring-projects › spring-boot › issues › 5929
Consider replacing org.json in spring-boot-configuration-processor due to licence · Issue #5929 · spring-projects/spring-boot
May 12, 2016 - Using Spring Boot 1.3.4, we recognized that spring boot is using the json library. Details here: https://wiki.debian.org/qa.debian.org/jsonevil · Dependency graph: --- org.springframework.boot:spring-boot-configuration-processor:1.3.4.RELEASE +--- org.json:json:20140107 --- org.springframework:spring-core:4.2.4.RELEASE (*) Reactions are currently unavailable ·
Published   May 12, 2016
Author   jgoldhammer
🌐
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
🌐
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

🌐
GitHub
github.com › spring-cloud › spring-cloud-function › issues › 1156
Found multiple occurrences of org.json.JSONObject on the class path · Issue #1156 · spring-cloud/spring-cloud-function
June 28, 2024 - Found multiple occurrences of org.json.JSONObject on the class path: jar:file:/Users/xxxx/.m2/repository/org/json/json/20240303/json-20240303.jar!/org/json/JSONObject.class jar:file:/Users/xxxx/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/org/json/JSONObject.class ... Workaround : exclude android-json from the test dependencies (seems the safer bet, in order to have the same version that the one that will run in prod) : <exclusions> <exclusion> <groupId>com.vaadin.external.google</groupId> <artifactId>android-json</artifactId> </exclusion> </exclusions> but it's a bit sad/messy to have to to that, and only do it for projects that use spring-cloud-function
Author   snussbaumer
Find elsewhere
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.

🌐
GitHub
github.com › spring-projects › spring-boot › issues › 45504
Use a shaded version of org.json in spring-boot-configuration-metadata and spring-boot-cli · Issue #45504 · spring-projects/spring-boot
May 12, 2025 - Hi, spring-boot-configuration-metadata has a dependency on com.vaadin.external.google:android-json:0.0.20131108.vaadin1 (managed here). This library was last released in 2013, and having it on the classpath often causes warnings like · Found multiple occurrences of org.json.JSONObject on the class path: jar:file:/Users/tschut/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/org/json/JSONObject.class jar:file:/Users/tschut/.m2/repository/org/json/json/20250107/json-20250107.jar!/org/json/JSONObject.class
Published   May 12, 2025
Author   tschut
🌐
GitHub
github.com › spring-projects › spring-boot › issues › 32881
Warning about multiple occurrences of `org.json.JSONObject` · Issue #32881 · spring-projects/spring-boot
October 26, 2022 - Since its 4.0.0 release, Jedis pulls in org.json:json as a transitive dependency. At the same time, com.vaadin.external.google:android-json is pulled in by org.skyscreamer:jsonassert which in turn is a dependency of spring-boot-starter-test.
Author   vpavic
🌐
Spring
docs.spring.io › spring-boot › docs › 2.3.0.M4 › api › org › springframework › boot › configurationprocessor › json › JSONObject.html
JSONObject (Spring Boot 2.3.0.M4 API)
April 20, 2023 - Index · Help · Prev Class · Next Class · Frames · No Frames · All Classes · Summary: Nested | Field | Constr | Method · Detail: Field | Constr | Method · org.springframework.boot.configurationprocessor.json · java.lang.Object · org.springframework.boot.configurationprocessor.json.JSONObject ·
🌐
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.
🌐
GitHub
github.com › spring-projects › spring-boot › issues › 3290
Add `org.json` dependency · Issue #3290 · spring-projects/spring-boot
We currently depend on org.json in Spring Boot but it's pulled in transitively. We should make it a top level dependency.
🌐
Maven Central
central.sonatype.com › artifact › org.springframework.boot › spring-boot-starter-json › 2.3.3.RELEASE
spring-boot-starter-json - Maven Central - Sonatype
pkg:maven/org.springframework.boot/spring-boot-starter-json@2.3.3.RELEASE ... <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-json</artifactId> <version>2.3.3.RELEASE</version> </dependency>
🌐
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 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 ...