Import JSON into an Eclipse project

I am a beginner Java programmer who wants to use JSON in a project. I followed a programming tutorial (from a book) that asked me to import JSON into my project using the following line:

import com.google.appengine.repackaged.org.json.JSONArray; 

But this caused an error, so I replaced it with this line:

 import org.json.JSONArray; 

This also creates a (other) error:

Unable to allow org.json import

I think the problem is that I actually don't have a JSON library in the Eclipse workspace. How can I do this, so I can use JSONArray? I found a site for JSON, but I'm not sure what to download or how and where to install it:

http://json.org/java/

+52
java json eclipse import
Jan 25 2018-12-12T00:
source share
6 answers

Download the ZIP file from this URL and extract it to get a Jar. Add a Jar to the build path. To check the available classes in this bank, use this URL .

To add this Jar to your build path Right-click Project> Build Path> Configure Build Path> Select the Libraries tab> Click Add External Libraries> Select the Jar File Download

I hope this solves your problem.

+114
Jan 25 2018-12-12T00:
source share
— -

You should take the json implementation from here: http://code.google.com/p/json-simple/ .

  • Download * .jar
  • Add it to the classpath (right-click on the project, Properties-> Libraries and add a new JAR.)
+4
Jan 25 2018-12-12T00:
source share

It still doesn't work for me, but at least I no longer get the JSON library error. Copy json-1.5.jar to the main folder from here the link , not to the library, and then replace each import com.google.appengine.repackaged.org.json.JSONArray; on import org.json.JSONArray; as you indicated. However, I get the following warning every time I try to access the data store:

 com.google.appengine.tools.development.LocalResourceFileServlet doGet WARNING: No file found for: /favicon.ico 

Did you manage to complete the work with the code?

+1
Feb 25 2018-12-25T00:
source share

Download json from java2s website and then include it in your project. In your class add these java_basic package;

 import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.Iterator; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; 
+1
Oct 05 '16 at 11:30
source share

Download json jar from here . This will solve your problem.

-one
Aug 24 '16 at 0:37
source share

Download here java-json.jar which contains org.json.JSONArray

http://www.java2s.com/Code/JarDownload/java/java-json.jar.zip

nzip and add to your project library: Project> Build path> Configure build path> Select the Library tab> Add external libraries> Select the java-json.jar file.

-3
Dec 12 '15 at 12:58
source share



All Articles