Package org.codehaus.jettison.json

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


            JSONObject paramMap = requestObject.optJSONObject(PARAMS);
            if (paramMap != null) {
                final Iterator keyIterator = paramMap.keys();
                while (keyIterator.hasNext()) {
                    final String key = (String) keyIterator.next();
                    bindings.put(key, ElementHelper.getTypedPropertyValue(paramMap.opt(key), parseTypes));
                }
            }
        }
    }
View Full Code Here


                HashMap<String, Object> properties = new HashMap<String, Object>();

                Iterator itty = innerJson.keys();
                while (itty.hasNext()) {
                    String key = (String) itty.next();
                    properties.put(key, getTypedPropertyValue(innerJson.opt(key), parseTypes));
                }

                typedPropertyValue = properties;
            } else if (propertyValue instanceof JSONArray) {
                JSONArray innerJson = (JSONArray) propertyValue;
View Full Code Here

            } else if (propertyValue instanceof JSONArray) {
                JSONArray innerJson = (JSONArray) propertyValue;
                ArrayList typedItems = new ArrayList();

                for (int ix = 0; ix < innerJson.length(); ix++) {
                    typedItems.add(getTypedPropertyValue(innerJson.opt(ix), parseTypes));
                }

                typedPropertyValue = typedItems;
            }
        }
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

        ExtensionMethod extensionMethod = new ExtensionMethod(null, null, extensionDescriptor, null);
        JSONObject api = extensionMethod.getExtensionApiAsJson();

        Assert.assertNotNull(api);
        Assert.assertTrue(api.has(Tokens.DESCRIPTION));
        Assert.assertEquals("desc", api.opt(Tokens.DESCRIPTION));
        Assert.assertFalse(api.has(Tokens.PARAMETERS));
    }

    @Test
    public void getExtensionApiAsJsonParameterOnlyNoApiElements() {
View Full Code Here

        ExtensionMethod extensionMethod = new ExtensionMethod(methods[0], null, extensionDescriptor, null);
        JSONObject api = extensionMethod.getExtensionApiAsJson();

        Assert.assertNotNull(api);
        Assert.assertTrue(api.has(Tokens.DESCRIPTION));
        Assert.assertEquals("desc", api.opt(Tokens.DESCRIPTION));
        Assert.assertFalse(api.has(Tokens.PARAMETERS));
    }

    @Test
    public void getExtensionApiAsJsonDefaultNoApiElements() {
View Full Code Here

        ExtensionMethod extensionMethod = new ExtensionMethod(methods[0], null, extensionDescriptor, null);
        JSONObject api = extensionMethod.getExtensionApiAsJson();

        Assert.assertNotNull(api);
        Assert.assertTrue(api.has(Tokens.DESCRIPTION));
        Assert.assertEquals("desc", api.opt(Tokens.DESCRIPTION));
        Assert.assertFalse(api.has(Tokens.PARAMETERS));
    }

    @Test
    public void getExtensionApiAsJsonDescriptorOnlyHasApiElements() {
View Full Code Here

        ExtensionMethod extensionMethod = new ExtensionMethod(null, null, extensionDescriptor, null);
        JSONObject api = extensionMethod.getExtensionApiAsJson();

        Assert.assertNotNull(api);
        Assert.assertTrue(api.has(Tokens.DESCRIPTION));
        Assert.assertEquals("desc", api.opt(Tokens.DESCRIPTION));
        Assert.assertTrue(api.has(Tokens.PARAMETERS));

        JSONObject params = api.optJSONObject(Tokens.PARAMETERS);
        Assert.assertNotNull(params);
        Assert.assertTrue(params.has("param1"));
View Full Code Here

        ExtensionMethod extensionMethod = new ExtensionMethod(methods[0], null, extensionDescriptor, null);
        JSONObject api = extensionMethod.getExtensionApiAsJson();

        Assert.assertNotNull(api);
        Assert.assertTrue(api.has(Tokens.DESCRIPTION));
        Assert.assertEquals("desc", api.opt(Tokens.DESCRIPTION));
        Assert.assertTrue(api.has(Tokens.PARAMETERS));

        JSONObject params = api.optJSONObject(Tokens.PARAMETERS);
        Assert.assertNotNull(params);
        Assert.assertTrue(params.has("nme"));
View Full Code Here

        ExtensionMethod extensionMethod = new ExtensionMethod(methods[0], null, extensionDescriptor, null);
        JSONObject api = extensionMethod.getExtensionApiAsJson();

        Assert.assertNotNull(api);
        Assert.assertTrue(api.has(Tokens.DESCRIPTION));
        Assert.assertEquals("desc", api.opt(Tokens.DESCRIPTION));
        Assert.assertTrue(api.has(Tokens.PARAMETERS));

        JSONObject params = api.optJSONObject(Tokens.PARAMETERS);
        Assert.assertNotNull(params);
        Assert.assertTrue(params.has("nme"));
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.