Package org.apache.sling.commons.json

Examples of org.apache.sling.commons.json.JSONObject.keys()


                while (files.hasMoreElements()) {
                    final InputStream stream = files.nextElement().openStream();
                    final String contents = IOUtils.toString(stream);
                    IOUtils.closeQuietly(stream);
                    final JSONObject obj = new JSONObject(contents);
                    for (final Iterator<String> adaptableNames = obj.keys(); adaptableNames.hasNext();) {
                        final String adaptableName = adaptableNames.next();
                        final JSONObject adaptable = obj.getJSONObject(adaptableName);
                        for (final Iterator<String> conditions = adaptable.keys(); conditions.hasNext();) {
                            final String condition = conditions.next();
                            String[] adapters;
View Full Code Here


                    IOUtils.closeQuietly(stream);
                    final JSONObject obj = new JSONObject(contents);
                    for (final Iterator<String> adaptableNames = obj.keys(); adaptableNames.hasNext();) {
                        final String adaptableName = adaptableNames.next();
                        final JSONObject adaptable = obj.getJSONObject(adaptableName);
                        for (final Iterator<String> conditions = adaptable.keys(); conditions.hasNext();) {
                            final String condition = conditions.next();
                            String[] adapters;
                            final Object value = adaptable.get(condition);
                            if (value instanceof JSONArray) {
                                adapters = toStringArray((JSONArray) value);
View Full Code Here

            final JSONObject anInstance) throws JSONException {
        final boolean isLeader = anInstance.getBoolean("isLeader");
        final String slingId = anInstance.getString("slingId");

        final JSONObject propertiesObj = anInstance.getJSONObject("properties");
        Iterator<String> it = propertiesObj.keys();
        Map<String, String> properties = new HashMap<String, String>();
        while (it.hasNext()) {
            String key = it.next();
            properties.put(key, propertiesObj.getString(key));
        }
View Full Code Here

        final String toDelete = uploadTestScript("builder_object.groovy","json.groovy");
        try {
            final String content = getContent(displayUrl + ".json", CONTENT_TYPE_JSON);
            JSONObject jo = new JSONObject(content);
            assertEquals("Content contained wrong number of items", 1, jo.length());
            assertEquals("Content contained wrong key", "text", jo.keys().next());
            assertEquals("Content contained wrong data", testText, jo.get("text"));
        } finally {
            testClient.delete(toDelete);
        }
    }
View Full Code Here

            for (String value : values) {

                try {
                    JSONObject parsed = new JSONObject(value);
                    Map<String, String> columnMap = new HashMap<String, String>();
                    for (Iterator<String> iter = parsed.keys(); iter.hasNext();) {
                        String key = iter.next();
                        String innerValue = parsed.getString(key);
                        columnMap.put(key, innerValue);
                    }
View Full Code Here

            }

// Loop thru the keys.

            jo = (JSONObject)o;
            keys = jo.keys();
            while (keys.hasNext()) {
                k = keys.next();
                v = jo.get(k);
                if (v instanceof String) {
                    s = (String)v;
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.