Package org.codehaus.jettison.json

Examples of org.codehaus.jettison.json.JSONException


    @Override
    public T parse(JSONObject json) throws JSONException {
      final JSONObject valueObject = json.optJSONObject(VALUE_ATTRIBUTE);
      if (valueObject == null) {
        throw new JSONException("Expected JSONObject with [" + VALUE_ATTRIBUTE + "] attribute present.");
      }
      return jsonParser.parse(valueObject);
    }
View Full Code Here


        return null;
      }
      try {
        return Double.parseDouble(s);
      } catch (NumberFormatException e) {
        throw new JSONException("[" + s + "] is not a valid floating point number");
      }
    }
View Full Code Here

  private <T> T convert(Object o, Class<T> clazz) throws JSONException {
    try {
      return clazz.cast(o);
    } catch (ClassCastException e) {
      throw new JSONException("Expected [" + clazz.getSimpleName() + "], but found [" + o.getClass().getSimpleName() + "]");
    }
  }
View Full Code Here

    if (ROLE_TYPE.equalsIgnoreCase(type)) {
      visibilityType = Visibility.Type.ROLE;
    } else if (GROUP_TYPE.equalsIgnoreCase(type)) {
      visibilityType = Visibility.Type.GROUP;
    } else {
      throw new JSONException("[" + type + "] does not represent a valid visibility type. Expected ["
          + ROLE_TYPE + "] or [" + GROUP_TYPE + "].");
    }
    final String value = json.getString("value");
    return new Visibility(visibilityType, value);
  }
View Full Code Here

    final Iterator iterator = jsonObject.keys();
    while (iterator.hasNext()) {
      final Object o = iterator.next();
      if (!(o instanceof String)) {
        throw new JSONException(
            "Cannot parse URIs: key is expected to be valid String. Got " + (o == null ? "null" : o.getClass())
                + " instead.");
      }
      final String key = (String) o;
      uris.put(key, JsonParseUtil.parseURI(jsonObject.getString(key)));
View Full Code Here

    if ("jira".equalsIgnoreCase(fieldTypeStr)) {
      fieldType = FieldType.JIRA;
    } else if ("custom".equalsIgnoreCase(fieldTypeStr)) {
      fieldType = FieldType.CUSTOM;
    } else {
      throw new JSONException("[" + fieldTypeStr + "] does not represent a valid field type. Expected [jira] or [custom].");
    }
    final String field = JsonParseUtil.getNestedString(json, "field");
    final String from = JsonParseUtil.getNullableString(json, "from");
    final String fromString = JsonParseUtil.getNullableString(json, "fromString");
    final String to = JsonParseUtil.getNullableString(json, "to");
View Full Code Here

  @Override
  public String parse(Object o) throws JSONException {
    try {
      return (String) o;
    } catch (ClassCastException e) {
      throw new JSONException(
          "Expected [" + String.class.getSimpleName() + "], but found [" + o.getClass().getSimpleName() + "]");
    }
  }
View Full Code Here

      return ((JSONObject) summaryObject).getString(VALUE_ATTR);
    }
    if (summaryObject instanceof String) { // JIRA 5.0 way
      return (String) summaryObject;
    }
    throw new JSONException("Cannot parse [" + attributeName + "] from available fields");
  }
View Full Code Here

        // we should use fieldParser here (some new version as the old one probably won't work)
        // enable IssueJsonParserTest#testParseIssueWithUserPickerCustomFieldFilledOut after fixing this
        final Object value = json.opt(key);
        res.add(new IssueField(key, namesMap.get(key), typesMap.get("key"), value != JSONObject.NULL ? value : null));
      } catch (final Exception e) {
        throw new JSONException("Error while parsing [" + key + "] field: " + e.getMessage()) {
          @Override
          public Throwable getCause() {
            return e;
          }
        };
View Full Code Here

      JSONObject node = nodes.getJSONObject(i);
      if (node.has("couchApiBase")) {
        try {
          nodeUrls.add(new URL(node.getString("couchApiBase")));
        } catch (MalformedURLException e) {
          throw new JSONException("Got bad couchApiBase URL from config");
        }
      }
    }
    return nodeUrls;
  }
View Full Code Here

TOP

Related Classes of org.codehaus.jettison.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.