Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use JSONObject in Google App Engine (Java) anymore?

Half an hour ago I opened Eclipse to edit a Google App Engine app, previously everything was working fine, no errors, I haven't updated anything (at least not knowingly).

I had imported: com.google.appengine.repackaged.org.json.JSONObject without error, however now I get this error:

use of com.google.appengine.repackaged may result in your app breaking without warning

It has never broken before, it came with the Google App Engine download for Eclipse, why has it suddenly started now? And how can I get rid of it? (they change I was making was very small and quick, it would be nice not to have to use a different JSON library)

like image 665
Jonathan. Avatar asked Jan 03 '12 15:01

Jonathan.


3 Answers

com.google.appengine.repackaged.* contains internal classes that should not be used by application code.

org.json is implemented by many libraries, for example JSON-Java. Simply include one of them in your GAE project.

like image 126
Peter Knego Avatar answered Oct 22 '22 17:10

Peter Knego


In case you don't want to have to figure this all out from first principles, here is a step-by-step:

  1. Get the sources from https://github.com/douglascrockford/JSON-java (you can download the zip, use Git, etc.)
  2. Make a directory in your project json/org/json and put the sources in there.
  3. Use "Refresh" in Eclipse so that it sees and compiles the directory.
  4. Change all the "import com.google.appengine.repackaged.org.json.xxx;" to "import org.json.xxx;" in your code

Unfortunately this adds a whole lot of Warnings, but they do seem to be harmless.

like image 2
Allan Miller Avatar answered Oct 22 '22 17:10

Allan Miller


AppEngine 1.8.4 use

com.google.appengine.labs.repackaged.org.json.JSONObject

like image 4
jumanor Avatar answered Oct 22 '22 17:10

jumanor