Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Documentation
Sidebar

Class JSONException

Hierarchy

java.lang.Object
     java.lang.Throwable
         java.lang.Exception

Package
org.json

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 {@link Double#isNaN() NaNs} or {@link Double#isInfinite() 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);
     }
 }

Constructors

JSONException( String s )

public JSONException(String s)

Parameters

s

JSONException( String message, Throwable cause )

public JSONException(String message,Throwable cause)

Parameters

message
cause

JSONException( Throwable cause )

public JSONException(Throwable cause)

Parameters

cause

Methods

Inherited Methods

From Class Methods
java.lang.Throwable getMessage, getLocalizedMessage, getCause, initCause, toString, printStackTrace, printStackTrace, printStackTrace, fillInStackTrace, getStackTrace, setStackTrace, addSuppressed, getSuppressed
java.lang.Object getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize
View on GitHub.com
Previous Section Next Section