Package org.json

Class JSONException

  • All Implemented Interfaces:
    java.io.Serializable

    public class JSONException
    extends java.lang.Exception
    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);
         }
     }
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONException​(java.lang.String s)  
      JSONException​(java.lang.String message, java.lang.Throwable cause)  
      JSONException​(java.lang.Throwable cause)  
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • JSONException

        public JSONException​(java.lang.String s)
      • JSONException

        public JSONException​(java.lang.String message,
                             java.lang.Throwable cause)
      • JSONException

        public JSONException​(java.lang.Throwable cause)