Package org.codehaus.jettison.json

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


        JSONArray listAsJSON = listWithTypeAsJson.optJSONArray(GraphSONTokens.VALUE).optJSONObject(0).getJSONArray(GraphSONTokens.VALUE);
        Assert.assertNotNull(listAsJSON);
        Assert.assertEquals(3, listAsJSON.length());

        for (int ix = 0; ix < listAsJSON.length(); ix++) {
            JSONObject valueAsJson = listAsJSON.optJSONObject(ix);
            Assert.assertNotNull(valueAsJson);
            Assert.assertTrue(valueAsJson.has(GraphSONTokens.TYPE));
            Assert.assertEquals(GraphSONTokens.TYPE_INTEGER, valueAsJson.optString(GraphSONTokens.TYPE));
            Assert.assertTrue(valueAsJson.has(GraphSONTokens.VALUE));
            Assert.assertEquals(1, valueAsJson.optInt(GraphSONTokens.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

            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

        }
        reconcileQuery.setLimit(jQuery.optInt("limit", DEFAULT_LIMIT));
        JSONArray jProperties = jQuery.optJSONArray("properties");
        if(jProperties != null){
            for(int i=0;i<jProperties.length();i++){
                parseProperty(reconcileQuery, jProperties.optJSONObject(i));
            }
        }
        return reconcileQuery;
    }
View Full Code Here

        Assert.assertEquals(2, results.length());

        boolean rowMatchX = false;
        boolean rowMatchY = false;
        for (int ix = 0; ix < results.length(); ix++) {
            JSONObject row = results.optJSONObject(ix);

            Assert.assertNotNull(row);
            Assert.assertTrue(row.has("col1"));
            Assert.assertTrue(row.has("col2"));
View Full Code Here

        Assert.assertEquals(2, results.length());

        boolean rowMatchZ = false;
        boolean rowMatchY = false;
        for (int ix = 0; ix < results.length(); ix++) {
            JSONObject row = results.optJSONObject(ix);

            Assert.assertNotNull(row);
            Assert.assertTrue(row.has("col1"));
            Assert.assertTrue(row.has("col2"));
View Full Code Here

        JSONArray converted = converter.convert(iterable);

        Assert.assertNotNull(converted);
        Assert.assertEquals(1, converted.length());

        JSONObject vertexAsJson = converted.optJSONObject(0);
        Assert.assertNotNull(vertexAsJson);

        JSONObject friendsProperty = vertexAsJson.optJSONObject("friends");
        Assert.assertEquals("list", friendsProperty.getString("type"));
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.