# Print output for @column tags ?> JSONException - Android SDK | Android Developers

Most visited


Recently visited


JSONException

public class JSONException
extends Exception

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


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)
JSONException(String message, Throwable cause)
JSONException(Throwable cause)

Inherited methods

Public constructors


JSONException

public JSONException (String s)

Parameters
s String

JSONException

public JSONException (String message, 
                Throwable cause)

Parameters
message String

cause Throwable

JSONException

public JSONException (Throwable cause)

Parameters
cause Throwable

Browse this site in English?

You requested a page in English, but your language preference for this site is English.

Would you like to change your language preference and browse this site in English? If you want to change your language preference later, use the language menu at the bottom of each page.