0

I am importing org.json.JSONObject and maven is using version 20140107. I don't think the version is the issue since maven properties are fetched directly from master which everyone else is using. But I also tried a newer version instead but I still got the same error. It's almost as if eclipse isn't using org.json, but I've made sure that it is.

Could this be a jre issue? Has anyone else encountered a similar issue with org.json.JSONObject?

Javier
  • 39
  • 6
  • How do you import that jar, can you post your pom.xml? Did you get that error during compiling phase? What's the code that throw the error? – WoAiNii May 11 '20 at 19:49
  • This is the dependency is the pom.xml : org.json json 20140107 Yes, I get it during compilation. The errors that I'm getting are 1. keySet() method not defined for org.json.JSONObject 2. org.json.JSONObject throws a JSONException (throughout the whole code) JSONObject create = new JSONObject().put("issueUpdates", new JSONArray()); – Javier May 11 '20 at 19:56
  • If I try creating the first org.json.JSONArray like here https://stackoverflow.com/questions/29170315/why-how-is-org-json-jsonexception-unchecked , I also get an unhandled exception JSONException. Basically my JSONException Extends Exception rather than RunTimeException. – Javier May 11 '20 at 20:08
  • I miss something, after maven update do you see the downloaded jar in your locale repository? I tried what you describe with no error. Can you post the code you're using for testing? – WoAiNii May 11 '20 at 20:26
  • Can't post the whole code unfortunately (its from work) but I've posted some pictures that might help https://imgur.com/a/6Lnav4i . I've also changed my jre to match the one that my colleagues have and I still have the same issue. – Javier May 11 '20 at 20:42
  • Are you sure you're not mixing version of JSONObject (org.json.simple.JSONObject and org.json.JSONObject)? Do you have any other errors in your project? – WoAiNii May 11 '20 at 21:04
  • I have a bunch of checked exceptions like this https://imgur.com/a/lxslOiE . JSONException extends Exception and not RunTimeException like it should according to its documentation. I don't think eclipse is using org.json.simple, I'm importing org.json.JSONObject – Javier May 11 '20 at 21:12
  • Version 20140107 has the keySet method and throws that exception, so you must be using an older/different version (like 20090211, that doesn't have that method). Try to redo a maven update and a clean build. – WoAiNii May 12 '20 at 06:51

0 Answers0