Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.json.simple.JSONObject VS org.json.JSONObject , JSONException cannot be resolved to a type

First: can someone provide an explanation of the differences between org.json.simple.JSONObject and org.json.JSONObject?

Second: I have a code with org.json.JSONObject and org.json.JSONException. When I edit the code in eclipse ( JUNO) it resolves the type of JSONException and imports the package org.json.JSONException but when I run the project using maven in command line I have a problem ( JSONException cannot be resolved to a type). I tried to solve the issue by adding dependency to pom.xml like this :

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

but I am not sure if it is the right one . I even download the jar of org. java-json.jar and add it to web deployment assembly but still the same error. Can anyone help ?

like image 530
Cooper Avatar asked Jul 30 '13 08:07

Cooper


People also ask

What is the difference between org JSON JSONObject and org JSON simple JSONObject?

simple package contains important classes like JSONValue, JSONObject, JSONArray, JsonString and JsonNumber. We need to install the json-simple. jar file to execute a JSON program whereas org. json library has classes to parse JSON for Java.


1 Answers

org.json and org.json.simple are two different Java libraries, which are incompatible with each other. The fact that they have the same name is only a misleading coincidence.

To compare the two libraries:

General comparison = http://www.rojotek.com/blog/2009/05/07/a-review-of-5-java-json-libraries/ org.json.simple = http://code.google.com/p/json-simple/
org.json = http://json.org/java

like image 111
James Game Avatar answered Sep 28 '22 22:09

James Game