1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.json; 18 19 // Note: this class was written without inspecting the non-free org.json sourcecode. 20 21 /** 22 * Thrown to indicate a problem with the JSON API. Such problems include: 23 * <ul> 24 * <li>Attempts to parse or construct malformed documents 25 * <li>Use of null as a name 26 * <li>Use of numeric types not available to JSON, such as {@link 27 * Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}. 28 * <li>Lookups using an out of range index or nonexistent name 29 * <li>Type mismatches on lookups 30 * </ul> 31 * 32 * <p>Although this is a checked exception, it is rarely recoverable. Most 33 * callers should simply wrap this exception in an unchecked exception and 34 * rethrow: 35 * <pre> public JSONArray toJSONObject() { 36 * try { 37 * JSONObject result = new JSONObject(); 38 * ... 39 * } catch (JSONException e) { 40 * throw new RuntimeException(e); 41 * } 42 * }</pre> 43 */ 44 public class JSONException extends Exception { 45 JSONException(String s)46 public JSONException(String s) { 47 super(s); 48 } 49 JSONException(String message, Throwable cause)50 public JSONException(String message, Throwable cause) { 51 super(message, cause); 52 } 53 JSONException(Throwable cause)54 public JSONException(Throwable cause) { 55 super(cause); 56 } 57 58 } 59