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

橙三吉。 提交于 2019-12-05 18:02:31

问题


Fist: an explanation of difference 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>

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 deployement assembly but still the same error. Anyone can help ?


回答1:


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



来源:https://stackoverflow.com/questions/17941743/org-json-simple-jsonobject-vs-org-json-jsonobject-jsonexception-cannot-be-reso

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!