I cannot import JSONObject, I thought this was something that came with java and an external jar is not needed, why is it saying it cannot find it?
Asked
Active
Viewed 3.4k times
2 Answers
6
I thought this was something that came with java and an external jar is not needed
No - JsonObject
is only in JavaEE. JSONObject
isn't included in JavaSE, it needs an external library. You can find it on github. However, if you use JavaEE, it is included.
If you are using gradle, add the following to your build.gradle
file (available in maven central):
dependencies {
compile "org.json:json:20171018"
}

msrd0
- 7,816
- 9
- 47
- 82
-
But i never had to do this before. I work a lot with JSONObject and JSONArray and I usually just create a new project and everything works – 124697 Oct 18 '14 at 12:32
-
@code578841441 It is only available in JavaEE, not in JavaSE - and in JavaEE it is lowercased (`JsonObject`) – msrd0 Oct 18 '14 at 12:34
2
You need to use the following library in Java SE: https://jsonp.java.net/
The JSR 353: Java API for JSON Processing
is only in Java EE by default, not in Java SE.

EpicPandaForce
- 79,669
- 27
- 256
- 428