Package org.codehaus.jettison.json

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


        final JSONArray propertyArray = requestObject.optJSONArray(Tokens._PROPERTIES);
        if (propertyArray != null) {
            try {
                final StringBuffer sb = new StringBuffer();
                for (int ix = 0; ix < propertyArray.length(); ix++) {
                    sb.append(propertyArray.optString(ix));

                    if (ix < propertyArray.length() - 1) {
                        sb.append(",");
                    }
                }
View Full Code Here


        JSONArray jsonResults = jsonResponse.optJSONArray("results");
        Assert.assertNotNull(jsonResults);
        Assert.assertEquals(4, jsonResults.length());

        Assert.assertEquals(3, jsonResults.optInt(0));
        Assert.assertEquals("test", jsonResults.optString(1));
        Assert.assertEquals(4, jsonResults.optInt(2));
        Assert.assertEquals(3, jsonResults.optInt(3));

    }
View Full Code Here

        assertNotNull("Result Query is missing the 'selected' property",jSelected);
        assertTrue("Result Query is expected to have at least a single selected field",
            jSelected.length() > 0);
        boolean found = false;
        for(int i=0;i<jSelected.length() && !found;i++){
            String selectedField = jSelected.optString(i,null);
            assertNotNull("Selected array contains a NULL element \n"+jSelected.toString(4),
                selectedField);
            selectedSet.remove(selectedField);
        }
        assertTrue("Fields "+selectedSet+" are not selected by\n"+jSelected.toString(4),
View Full Code Here

                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");
                    value[1] = null;
                    assertNotNull("All Field-values MUST have the 'value' property",value[0]);
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.