Org.json.simple.JSONObject VS org.json.JSONObject, JSONException cannot be allowed for type

Fist: explanation of the difference between org.json.simple.JSONObject and org.json.JSONObject ??

Secondly: I have code with org.json.JSONObject and org.json.JSONException. When I edit the code in eclipse (JUNO), it solves the JSON exception type and imports the org.json.JSONException package, but when I run the project using maven on the command line, I have a problem (JSONException cannot be resolved for the type). I tried to solve the problem by adding a dependency on pom.xml as follows:

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

but I'm not sure that it is correct. I even load the can of org. java-json.jar and add it to the web deployment assembly, but still the same error. Who can help?

+6
source share
1 answer

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

To compare 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

+9
source

Source: https://habr.com/ru/post/950602/


All Articles