2

As i have some issues while working with Android's JSON (i.e. org.json), so here i'm using json simple. But when i try to convert string into json object using json parser, such as,

JSONObject masterJson = (JSONObject) new JSONParser().parse(stringdata);

an error occur :

java.lang.NoClassDefFoundError: org.json.simple.JSONObject

Please suggest a method. Thanks in advance.

3
  • Consider maybe using prebuilt Java JSON library - json-simple is archived with last update year ago. Have you imported org.json.JSONArray; and org.json.JSONObject; ? Commented Oct 28, 2015 at 12:44
  • org.json.JSONArray and org.json.JSONObject has some others issues. that's why i started using json-simple. But in android, when i use JSONParser, the error appears. Commented Oct 28, 2015 at 12:51
  • 1
    Check stackoverflow.com/questions/27504508/… Commented Oct 28, 2015 at 13:10

3 Answers 3

1

From my experience, even if we add the respective jar file, it wont work properly. For adding an external jar file, i followed the steps below:

Right click on project in eclipse -> Buildpath -> Configure Build path -> Java Build Path (left Pane) -> Libraries(Tab) -> Add External Jars -> Select your jar and select ok.

But it didn't work. After googling a lot, i found that, after adding the jar file, select the "Order and Export" tab, then check the currently added external file, finally refresh the project. Then it will work perfectly.

Refer this question: How can I resolve this java.lang.NoClassDefFoundError: org.json.simple.JSONObject error? In this question, we cant find an answere, but the correct answere was added as a comment. Thanks to @peeskillet for adding the comment.

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

Comments

0

Looks like you have missed including the filename.jar in your classpath. Include the same and it should get solved.

Hope this helps !

Comments

0

If there's problem with import .jar try something else.

Do you use gradle? If yes import in dependencies this line: compile 'com.googlecode.json-simple:json-simple:1.1'

1 Comment

i use ADT (Eclipse version)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.