482483484485486487488489490
if (o == null) { put(key, new JsonArray().put(value)); } else if (o instanceof JsonArray) { put(key, ((JsonArray) o).put(value)); } else { throw new JsonException("JsonObject[" + key + "] is not a JsonArray."); } return this; }
526527528529530531532533534
* if the key is not found. */ public Object get(String key) { Object o = opt(key); if (o == null) { throw new JsonException("JsonObject[" + quote(key) + "] not found."); } return o; }
547548549550551552553
if (o.equals(Boolean.FALSE) || (o instanceof String && ((String) o).equalsIgnoreCase("false"))) { return false; } else if (o.equals(Boolean.TRUE) || (o instanceof String && ((String) o).equalsIgnoreCase("true"))) { return true; } throw new JsonException("JsonObject[" + quote(key) + "] is not a Boolean."); }
565566567568569570571572
public double getDouble(String key) { Object o = get(key); try { return o instanceof Number ? ((Number) o).doubleValue() : Double.valueOf((String) o).doubleValue(); } catch (Exception e) { throw new JsonException("JsonObject[" + quote(key) + "] is not a number."); } }
599600601602603604605
public JsonArray getJsonArray(String key) { Object o = get(key); if (o instanceof JsonArray) { return (JsonArray) o; } throw new JsonException("JsonObject[" + quote(key) + "] is not a JsonArray."); }
616617618619620621622
public JsonObject getJsonObject(String key) { Object o = get(key); if (o instanceof JsonObject) { return (JsonObject) o; } throw new JsonException("JsonObject[" + quote(key) + "] is not a JsonObject."); }
635636637638639640641642
public long getLong(String key) { Object object = get(key); try { return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object); } catch (Exception e) { throw new JsonException("JSONObject[" + quote(key) + "] is not a long."); } }
763764765766767768769770771772773
* @throws JsonException * If n is a non-finite number. */ static public String numberToString(Number n) { if (n == null) { throw new JsonException("Null pointer"); } testValidity(n); // Shave off trailing zeros and decimal point, if possible.
10861087108810891090109110921093109410951096
* @throws JsonException * If the value is non-finite number or if the key is null. */ public JsonObject put(String key, Object value) { if (key == null) { throw new JsonException("Null key."); } if (value != null) { testValidity(value); this.map.put(key, value); } else {
11111112111311141115111611171118111911201121
* if the key is a duplicate */ public JsonObject putOnce(String key, Object value) { if (key != null && value != null) { if (opt(key) != null) { throw new JsonException("Duplicate key \"" + key + "\""); } put(key, value); } return this; }