Package org.codehaus.jettison.json

Examples of org.codehaus.jettison.json.JSONException


      type = "customFieldOption";
    }
    @SuppressWarnings("unchecked")
    final JsonObjectParser<Object> jsonParser = registeredAllowedValueParsers.get(type);
    if (jsonParser == null) {
      throw new JSONException("Cannot find parser for field witch schema: " + fieldSchema);
    }
    else {
      return jsonParser;
    }
  }
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

    @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 ("jira".equalsIgnoreCase(fieldTypeStr)) {
      fieldType = ChangelogItem.FieldType.JIRA;
    } else if ("custom".equalsIgnoreCase(fieldTypeStr)) {
      fieldType = ChangelogItem.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

      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

          continue;
        }
        final Object value = json.opt(key);
        res.add(new Field(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

            }
            back();

            String s = sb.toString().trim();
            if (s.length() == 0) {
                throw new JSONException("Missing value.");
            }
            Object res = null;
            if (s.equalsIgnoreCase("true")) {
                res = Boolean.TRUE;
            } else if (s.equalsIgnoreCase("false")) {
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.