Package ar.com.restba.json

Examples of ar.com.restba.json.JsonException


   */
  static void testValidity(Object o) {
    if (o != null) {
      if (o instanceof Double) {
        if (((Double) o).isInfinite() || ((Double) o).isNaN()) {
          throw new JsonException("JSON does not allow non-finite numbers.");
        }
      } else if (o instanceof Float) {
        if (((Float) o).isInfinite() || ((Float) o).isNaN()) {
          throw new JsonException("JSON does not allow non-finite numbers.");
        }
      }
    }
  }
View Full Code Here


    if (value instanceof JsonString) {
      Object o;
      try {
        o = ((JsonString) value).toJsonString();
      } catch (Exception e) {
        throw new JsonException(e);
      }
      if (o instanceof String) {
        return (String) o;
      }
      throw new JsonException("Bad value from toJSONString: " + o);
    }
    if (value instanceof Number) {
      return numberToString((Number) value);
    }
    if (value instanceof Boolean || value instanceof JsonObject || value instanceof JsonArray) {
View Full Code Here

        b = true;
      }
      writer.write('}');
      return writer;
    } catch (IOException e) {
      throw new JsonException(e);
    }
  }
View Full Code Here

      int length = Array.getLength(array);
      for (int i = 0; i < length; i += 1) {
        this.put(Array.get(array, i));
      }
    } else {
      throw new JsonException("JsonArray initial value should be a string or collection or array.");
    }
  }
View Full Code Here

        } else {
          this.myArrayList.add(new JsonObject(o, includeSuperClass));
        }
      }
    } else {
      throw new JsonException("JsonArray initial value should be a string or collection or array.");
    }
  }
View Full Code Here

   *           If there is no value for the index.
   */
  public Object get(int index) {
    Object o = opt(index);
    if (o == null) {
      throw new JsonException("JsonArray[" + index + "] 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("JsonArray[" + index + "] is not a Boolean.");
  }
View Full Code Here

  public double getDouble(int index) {
    Object o = get(index);
    try {
      return o instanceof Number ? ((Number) o).doubleValue() : Double.valueOf((String) o).doubleValue();
    } catch (Exception e) {
      throw new JsonException("JsonArray[" + index + "] is not a number.");
    }
  }
View Full Code Here

  public JsonArray getJsonArray(int index) {
    Object o = get(index);
    if (o instanceof JsonArray) {
      return (JsonArray) o;
    }
    throw new JsonException("JsonArray[" + index + "] is not a JsonArray.");
  }
View Full Code Here

  public JsonObject getJsonObject(int index) {
    Object o = get(index);
    if (o instanceof JsonObject) {
      return (JsonObject) o;
    }
    throw new JsonException("JsonArray[" + index + "] is not a JsonObject.");
  }
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.