Package org.codehaus.jettison.json

Examples of org.codehaus.jettison.json.JSONObject.opt()


      final String key = iterator.next();
      try {
        if (SPECIAL_FIELDS.contains(key)) {
          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() {
View Full Code Here


            obj = obj.getJSONObject("command");
            CachedCommandModel cm = new CachedCommandModel(obj.getString("@name"), etag);
            cm.dashOk = obj.optBoolean("@unknown-options-are-operands", false);
            cm.managedJob = obj.optBoolean("@managed-job", false);
            cm.setUsage(obj.optString("usage", null));
            Object optns = obj.opt("option");
            if (!JSONObject.NULL.equals(optns)) {
                JSONArray jsonOptions;
                if (optns instanceof JSONArray) {
                    jsonOptions = (JSONArray) optns;
                } else {
View Full Code Here

            obj = obj.getJSONObject("command");
            CachedCommandModel cm = new CachedCommandModel(obj.getString("@name"), etag);
            cm.dashOk = obj.optBoolean("@unknown-options-are-operands", false);
            cm.managedJob = obj.optBoolean("@managed-job", false);
            cm.setUsage(obj.optString("usage", null));
            Object optns = obj.opt("option");
            if (!JSONObject.NULL.equals(optns)) {
                JSONArray jsonOptions;
                if (optns instanceof JSONArray) {
                    jsonOptions = (JSONArray) optns;
                } else {
View Full Code Here

          continue;
        }
        // TODO: JRJC-122
        // 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() {
View Full Code Here

        final Map<String, Object> data = new HashMap<String, Object>();
        data.put(RexsterTokens.CLASS, c);
        final JSONObject json = new JSONObject(data);

        final JSONObject index = RestHelper.postResultObject(this.graphURI + RexsterTokens.SLASH_INDICES_SLASH + RestHelper.encode(indexName), json);
        if (!index.opt(RexsterTokens.NAME).equals(indexName))
            throw new RuntimeException("Could not create index: " + index.optString(RexsterTokens.MESSAGE));

        return new RexsterIndex<T>(this, indexName, indexClass);
    }
View Full Code Here

        else
            rawElement = RestHelper.getResultObject(this.graph.getGraphURI() + RexsterTokens.SLASH_EDGES_SLASH + RestHelper.encode(this.getId()) + RexsterTokens.QUESTION + RexsterTokens.REXSTER_SHOW_TYPES_EQUALS_TRUE);

        JSONObject typedProperty = rawElement.optJSONObject(key);
        if (null != typedProperty)
            return (T) RestHelper.typeCast(typedProperty.optString(RexsterTokens.TYPE), typedProperty.opt(RexsterTokens.VALUE));
        else
            return null;
    }

    public void setProperty(final String key, final Object value) {
View Full Code Here

            1, jConstraints.length());
        JSONObject constraint = jConstraints.optJSONObject(0);
        assertNotNull("'constraints' array does not contain a JSONObject but "+jConstraints.get(0),
            constraint);
       
        assertEquals("The 'type' of the Constraint is not 'text' but "+constraint.opt("type"),
            "text",constraint.optString("type"));

        assertEquals("The 'patternType' of the Constraint is not 'wildcard' but "+constraint.opt("patternType"),
            "wildcard",constraint.optString("patternType"));
       
View Full Code Here

            constraint);
       
        assertEquals("The 'type' of the Constraint is not 'text' but "+constraint.opt("type"),
            "text",constraint.optString("type"));

        assertEquals("The 'patternType' of the Constraint is not 'wildcard' but "+constraint.opt("patternType"),
            "wildcard",constraint.optString("patternType"));
       
        assertEquals("The 'field' of the Constraint is not "+getDefaultFindQueryField()+" but "+constraint.opt("field"),
            getDefaultFindQueryField(),constraint.optString("field"));
    }
View Full Code Here

            "text",constraint.optString("type"));

        assertEquals("The 'patternType' of the Constraint is not 'wildcard' but "+constraint.opt("patternType"),
            "wildcard",constraint.optString("patternType"));
       
        assertEquals("The 'field' of the Constraint is not "+getDefaultFindQueryField()+" but "+constraint.opt("field"),
            getDefaultFindQueryField(),constraint.optString("field"));
    }
    /**
     * Getter for the default field used for find queries of the 'field' parameter
     * is not defined.<p>
View Full Code Here

            obj = obj.getJSONObject("command");
            CachedCommandModel cm = new CachedCommandModel(obj.getString("@name"), etag);
            cm.dashOk = obj.optBoolean("@unknown-options-are-operands", false);
            cm.managedJob = obj.optBoolean("@managed-job", false);
            cm.setUsage(obj.optString("usage", null));
            Object optns = obj.opt("option");
            if (!JSONObject.NULL.equals(optns)) {
                JSONArray jsonOptions;
                if (optns instanceof JSONArray) {
                    jsonOptions = (JSONArray) optns;
                } else {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.