Importing JSON into an Netbeans project
Asked Answered
P

5

10

I need to import JSON library into netbeans.

How can I do that?

I searched on internet and I found this article.

According to this article when I import

import org.json.simple.JSONArray;
import org.json.simple.JSONObject

that, it must be work. But unfortunately it didn't work. and I get an error:

Package doesnt exist

Thanks for your help.

Professoriate answered 10/12, 2012 at 13:57 Comment(0)
S
6

As the article says you need to add the simple-json library to your project:

http://code.google.com/p/json-simple/

Shanna answered 10/12, 2012 at 14:7 Comment(0)
J
3

For this we have to add Class org.json.JSONObject which available in json-20131018.jar. We need to download this jar and add this jar to your buildpath.

for it in netbeans right click 'libraries' in the project list, then click add jar/folder.

Jaynajayne answered 3/6, 2016 at 7:50 Comment(0)
M
1

Download jar from here : https://code.google.com/archive/p/json-simple/downloads And then add it to your "libraries" in netbeans.

Added this answer, because other answer didn't provide the above link, which is the easiest to download jar from.

Mulford answered 13/7, 2016 at 17:44 Comment(0)
S
0

try add json-20131018.jar. This solved my problem. http://mvnrepository.com/artifact/org.json/json/20131018

Stickler answered 3/2, 2016 at 15:39 Comment(1)
Always add essential parts of the link into your answer.Moises
K
0

Or, instead of relying on the old version which uses the old import, use the newer version with the new import:

import com.github.cliftonlabs.json_simple.*;

For Netbeans, you can right click the project and go into Libraries to make sure the jar file is added into Classpath (not Modulepath). Press the '+' button to add it under that section by either by using a created library with the build jar and javadoc jar or, more simply, just adding the single jar file (json-simple-3.1.1.jar) directly to the classpath.

After doing this, the jar file should show up in the 'Libraries' folder under the project.

Kmeson answered 20/1, 2021 at 6:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.