Package ar.com.restba.json

Examples of ar.com.restba.json.JsonException


    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;
  }
View Full Code Here


   *           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;
  }
View Full Code Here

    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.");
  }
View Full Code Here

  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.");
    }
  }
View Full Code Here

  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.");
  }
View Full Code Here

  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.");
  }
View Full Code Here

  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.");
    }
  }
View Full Code Here

   * @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.

View Full Code Here

   * @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 {
View Full Code Here

   *           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;
  }
View Full Code Here

TOP

Related Classes of ar.com.restba.json.JsonException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.