Skip to content

JSON Java for Android developers

Sean Leary edited this page Jan 5, 2017 · 14 revisions

JSON-Java Compatibility: At the present time, JSON-Java maintains a level of Java JDK compatibility that allows it to be used by Android developers. This is not a project commitment, but it will be maintained for as long as possible.

Naming conflict with JSON-Java: The Android SDK already includes a subset of JSON-Java functionality. The Android package name is org.json, which conflicts with this project. Even if Android works with us to fix this problem, there is still the problem of this code being included in existing Android releases. So, here are some workarounds:

  • If all you want is basic, no-frills functionality, with no recent bug fixes, then just use the built in Android package.
  • If you want to include the JSON-Java lib for functionality only found in JSON-Java. For example, XML-JSON transformations provided by XML.java and other classes, then this may result in run time errors due to the conflict between the built-in org.json package and the JSON-Java org.json package. In this case, you may wish to refactor the JSON-Java source and build/import a local version of JSON-Java with a different package name.
  • For the XML problem, you may wish to try the workaround found here, where the problem is solved using a recursive copy: https://github.com/AppWerft/Ti.XML2Json/blob/master/android/src/de/appwerft/remotexml/JSON.java
Clone this wiki locally