Import org.json:json as gradle dependency


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:

group: ‘org.json’, name: ‘json’, version: ‘20201115’


implementation ‘org.json:json:20201115’

Any ideas please?
Still cannot import JSONObject in my beans.




Besides answering you concrete question: is there any reason why you don’t want to use Jackson? It comes out of the box with spring boot.

Just inject an instance of ObjectMapper in your beans in order to interact with it.


Add to build.gradle:

dependencies {
    implementation 'org.json:json:20211205'

Then refresh the project (see Load Gradle Changes popup at the top right corner of the editor, or click Reload All Gradle Projects in the Gradle tool window).

Thanks Konstantin, the “Refresh Gradle Dependencies” did the trick. I was only missing this step.

Replying to Mario, what I finally did is to use tomcat’s internal JSONParser which returns a Map, which is a very similar option too.

However I must say that for the sake of simplicity, org.json.JSONObject works like a charm.

Regards and many thanks to both for your answers.
Happy new year.

1 Like