Package org.codehaus.jettison.json

Examples of org.codehaus.jettison.json.JSONArray.optJSONObject()


        backoffRetry = tx.getInt(RETRY_KEY);
      }
      JSONArray array = tx.optJSONArray(TX_KEY);

      for (int i = 0; i < array.length(); i++) {
        JSONObject element = array.optJSONObject(i);
        createElement(element, graph, type);
      }

      Map<String, Object> resultMap = new HashMap<String, Object>();
      resultMap.put(Tokens.SUCCESS, true);
View Full Code Here


            if(!"id".equals(key)){
                Set<List<String>> values = new HashSet<List<String>>();
                JSONArray jValues = jRepresentation.getJSONArray(key.toString());
                assertTrue("Fields MUST contain at least a single value!",jValues.length() > 0);
                for(int i=0;i<jValues.length();i++){
                    JSONObject fieldValue = jValues.optJSONObject(i);
                    assertNotNull("Values for field "+key+" does contain an value " +
                        "that is not an JSONObject "+jValues.optString(i),
                        fieldValue);
                    String[] value = new String[2];
                    value[0] = fieldValue.optString("value");
View Full Code Here

       
        JSONArray jConstraints = jQuery.optJSONArray("constraints");
        assertNotNull("Result Query is missing the 'constraints' property",jConstraints);
        assertEquals("Result Query is expected to have a single constraint",
            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"));
View Full Code Here

        JSONObject jQuery = assertResponseQuery(re.getContent());
        JSONArray jConstraints = jQuery.optJSONArray("constraints");
        assertNotNull("Result Query does not contain the constraints Array",jConstraints);
        assertTrue("Result Query Constraint Array does not contain the expected Constraint",
            jConstraints.length() == 1);
        JSONObject jConstraint = jConstraints.optJSONObject(0);
        assertNotNull("Constraint Array does not contain JSONObjects",jConstraint);
        assertTrue("Returned Query does not contain the default data type",jConstraint.has("datatype"));
    }
    @Test
    public void testMissingTextConstraintTextProperty() throws IOException, JSONException {
View Full Code Here

        JSONObject jQuery = assertResponseQuery(re.getContent());
        JSONArray jConstraints = jQuery.optJSONArray("constraints");
        assertNotNull("Result Query does not contain the constraints Array",jConstraints);
        assertTrue("Result Query Constraint Array does not contain the expected Constraint",
            jConstraints.length() == 1);
        JSONObject jConstraint = jConstraints.optJSONObject(0);
        assertNotNull("Constraint Array does not contain JSONObjects",jConstraint);
        assertTrue("The 'patternType' property MUST BE set for returned TextConstraints",
            jConstraint.has("patternType"));
        assertEquals("Default for patternType MUST BE 'none'",
            "none", jConstraint.getString("patternType"));
View Full Code Here

        JSONObject jQuery = assertResponseQuery(re.getContent());
        JSONArray jConstraints = jQuery.optJSONArray("constraints");
        assertNotNull("Result Query does not contain the constraints Array",jConstraints);
        assertTrue("Result Query Constraint Array does not contain the expected Constraint",
            jConstraints.length() == 1);
        JSONObject jConstraint = jConstraints.optJSONObject(0);
        assertNotNull("Constraint Array does not contain JSONObjects",jConstraint);
        assertTrue("Returned Query does not contain the default data type",jConstraint.has("datatype"));    }  
}
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.