17

I'm a total java newbie and I have this problem. I try to decode Json and in order to do that I want to import these packages:

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

"The import cannot be resolved"... are these packages unavailable anymore or do I have to do something else in order to make them work?

Thanx in advance.

ABC123
  • 1,037
  • 2
  • 20
  • 44
baron_bartek
  • 1,073
  • 2
  • 20
  • 39

7 Answers7

15

Probably your simple json.jar file isn't in your classpath.

Arun Manivannan
  • 4,213
  • 3
  • 29
  • 38
13

I was facing same issue in my Spring Integration project. I added below JSON dependencies in pom.xml file. It works for me.

<dependency>
  <groupId>org.json</groupId>
  <artifactId>json</artifactId>
  <version>20090211</version>
</dependency>

A list of versions can be found here: https://mvnrepository.com/artifact/org.json/json

Katie
  • 45,622
  • 19
  • 93
  • 125
Pravin Mishra
  • 8,298
  • 4
  • 36
  • 49
  • 1
    Please note that you have to import differently than the question specified, specifically by leaving out the `.simple` suffix. Eg., `import org.json.JSONArray;` instead of `import org.json.simple.JSONArray;`. On the other hand, if you use `com.googlecode.json-simple` as [here](https://stackoverflow.com/a/49882661/6952495) then you can import as the question specified. The [docs for the package](https://github.com/stleary/JSON-java) say as much as well. – RyanQuey May 12 '20 at 04:40
8

try this

<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
    <groupId>com.googlecode.json-simple</groupId>
    <artifactId>json-simple</artifactId>
    <version>1.1.1</version>
</dependency>
mahdi
  • 89
  • 1
  • 4
  • 3
    Your answer would be more helpful (and more likely to receive upvotes) if you explain what your code does and why someone might choose to use this approach over the other 4 answers. – divibisan Apr 17 '18 at 16:20
  • this framework i used a lot jsonobject, jsonarray , parsing etc all required features are there . – Aditya Yada Feb 03 '21 at 14:54
3

The jar file is missing. You can download the jar file and add it as external libraries in your project . You can download this from

http://www.findjar.com/jar/com/googlecode/json-simple/json-simple/1.1/json-simple-1.1.jar.html

Heggi
  • 504
  • 4
  • 12
2

Try importing this in build.gradle dependencies

compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1'
saurabh yadav
  • 567
  • 6
  • 14
1

For a simple console program in vs code this worked for me: download the json-simple file from: https://code.google.com/archive/p/json-simple/downloads

Extract to your lib in your project folder then simple reference it.

J Maine
  • 23
  • 8
0

this works for me: https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple/1.1.1

<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
    <groupId>com.googlecode.json-simple</groupId>
    <artifactId>json-simple</artifactId>
    <version>1.1.1</version>
</dependency>
Adán Escobar
  • 1,729
  • 9
  • 15