Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public class

JSONException

extends Exception
java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ org.json.JSONException

Class Overview

Thrown to indicate a problem with the JSON API. Such problems include:

  • Attempts to parse or construct malformed documents
  • Use of null as a name
  • Use of numeric types not available to JSON, such as NaNs or infinities .
  • Lookups using an out of range index or nonexistent name
  • Type mismatches on lookups

Although this is a checked exception, it is rarely recoverable. Most callers should simply wrap this exception in an unchecked exception and rethrow:

        public JSONArray toJSONObject() {
     try {
         JSONObject result = new JSONObject();
         ...
     } catch (JSONException e) {
         throw new RuntimeException(e);
     }
 }
       

Summary

Public Constructors
JSONException ( String s)
[Expand]
Inherited Methods
From class java.lang.Throwable
From class java.lang.Object

Public Constructors

public JSONException ( String s)

Added in API level 1