Package org.codehaus.jettison.json

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


        //General NOTE:
        //  use opt**(..) methods to avoid JSON Exception. We want to parse
        //  everything and than do asserts!
        for(int i=0;i<results.length();i++){
            JSONObject result = results.getJSONObject(i);
            String id = result.optString("id", null);
            log.info("({}) {}",i,id);
            assertNotNull("ID missing for an Result", id);
            if(expectedIds != null){
                expectedIds.remove(id); //not all results must be in the list
            }
View Full Code Here


     */
    public static JSONObject assertEntity(String content,String id, String site) throws JSONException {
        assertNotNull("The content to parse the Entity from is NULL",content);
        JSONObject jEntity = new JSONObject(content);
        if(id != null){
            assertEquals("Entity has the wrong ID", id,jEntity.optString("id", null));
        } else {
            id = jEntity.optString("id", null);
            assertNotNull("ID of the Entity MUST NOT be NULL",id);
        }
        if(site != null){
View Full Code Here

        assertNotNull("The content to parse the Entity from is NULL",content);
        JSONObject jEntity = new JSONObject(content);
        if(id != null){
            assertEquals("Entity has the wrong ID", id,jEntity.optString("id", null));
        } else {
            id = jEntity.optString("id", null);
            assertNotNull("ID of the Entity MUST NOT be NULL",id);
        }
        if(site != null){
            assertEquals("Entity has the wrong Site", site, jEntity.optString("site",null));
        }
View Full Code Here

        } else {
            id = jEntity.optString("id", null);
            assertNotNull("ID of the Entity MUST NOT be NULL",id);
        }
        if(site != null){
            assertEquals("Entity has the wrong Site", site, jEntity.optString("site",null));
        }
       
        assertTrue("Representation is missing",jEntity.has("representation"));
        JSONObject jRepresentation = jEntity.getJSONObject("representation");
        assertNotNull("Representation is not an JSON Object",jRepresentation);
View Full Code Here

                    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]);
                    assertFalse("All Field-values MUST not be empty",value[0].isEmpty());
                    if(fieldValue.has("xsd:datatype")){
                        value[1] = fieldValue.getString("xsd:datatype");
View Full Code Here

            JSONObject obj = new JSONObject(str);
            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;
View Full Code Here

                    String type = jsOpt.getString("@type");
                    ParamModelData opt = new ParamModelData(
                            jsOpt.getString("@name"),
                            typeOf(type),
                            jsOpt.optBoolean("@optional", false),
                            jsOpt.optString("@default"),
                            jsOpt.optString("@short"),
                            jsOpt.optBoolean("@obsolete", false),
                            jsOpt.optString("@alias"));
                    opt.param._acceptableValues = jsOpt.optString("@acceptable-values");
                    if ("PASSWORD".equals(type)) {
View Full Code Here

                    ParamModelData opt = new ParamModelData(
                            jsOpt.getString("@name"),
                            typeOf(type),
                            jsOpt.optBoolean("@optional", false),
                            jsOpt.optString("@default"),
                            jsOpt.optString("@short"),
                            jsOpt.optBoolean("@obsolete", false),
                            jsOpt.optString("@alias"));
                    opt.param._acceptableValues = jsOpt.optString("@acceptable-values");
                    if ("PASSWORD".equals(type)) {
                        opt.param._password = true;
View Full Code Here

                            typeOf(type),
                            jsOpt.optBoolean("@optional", false),
                            jsOpt.optString("@default"),
                            jsOpt.optString("@short"),
                            jsOpt.optBoolean("@obsolete", false),
                            jsOpt.optString("@alias"));
                    opt.param._acceptableValues = jsOpt.optString("@acceptable-values");
                    if ("PASSWORD".equals(type)) {
                        opt.param._password = true;
                        opt.prompt = jsOpt.optString("@prompt");
                        opt.promptAgain = jsOpt.optString("@prompt-again");
View Full Code Here

                            jsOpt.optBoolean("@optional", false),
                            jsOpt.optString("@default"),
                            jsOpt.optString("@short"),
                            jsOpt.optBoolean("@obsolete", false),
                            jsOpt.optString("@alias"));
                    opt.param._acceptableValues = jsOpt.optString("@acceptable-values");
                    if ("PASSWORD".equals(type)) {
                        opt.param._password = true;
                        opt.prompt = jsOpt.optString("@prompt");
                        opt.promptAgain = jsOpt.optString("@prompt-again");
                    } else if ("FILE".equals(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.