21

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.

0

8 Answers 8

16

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

Sign up to request clarification or add additional context in comments.

3 Comments

Exactly right. If you never downloaded it, you can get it here: findjar.com/class/org/json/simple/JSONArray.html
Ok. I have it. The eclipse (android) directory is /libs . Thanx
14

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

1 Comment

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 then you can import as the question specified. The docs for the package say as much as well.
10

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>

2 Comments

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.
this framework i used a lot jsonobject, jsonarray , parsing etc all required features are there .
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

Comments

3

Try importing this in build.gradle dependencies

compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1'

Comments

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.

Comments

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>

Comments

0

Or in IntelliJ IDEA, go to:

Project Settings -> Libraries -> + -> From Maven... -> com.googlecode.json-simple:json-simple:1.1.1 -> OK

Then the code should work.

<dependency>
  <groupId>com.googlecode.json-simple</groupId>
  <artifactId>json-simple</artifactId>
  <version>1.1.1</version>
</dependency>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.