Package org.codehaus.jettison.json

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


                this.name = object.getString(KEY_NAME);
                this.activeSessionsCount = object.has("activeSessionsCount") ? object.getInt("activeSessionsCount") : 0;
                this.metadata = new LinkedHashMap<>();
                if (object.has("metadata")) {
                    JSONObject metadataObject = object.getJSONObject("metadata");
                    for (Iterator<String> keysIterator = metadataObject.keys(); keysIterator.hasNext(); ) {
                        String key = keysIterator.next();
                        Object value = metadataObject.get(key);
                        if (value instanceof JSONArray) {
                            JSONArray array = (JSONArray)value;
                            String[] strings = new String[array.length()];
View Full Code Here


    protected QueryResult(JSONObject object) {
        try {
            this.columns = new LinkedHashMap<>();
            if (object.has("columns")) {
                JSONObject columnsObject = object.getJSONObject("columns");
                Iterator<String> keysIterator = columnsObject.keys();
                while (keysIterator.hasNext()) {
                    String columnName = keysIterator.next();
                    String columnType = columnsObject.get(columnName).toString();
                    this.columns.put(columnName, columnType);
                }
View Full Code Here

         */
        JSONObject children = doPut("put/node_multiple_children_reorder1.json", itemsUrl(TEST_NODE)).isOk().json()
                                                                                                    .getJSONObject(CHILDREN_KEY);

        List<String> actualOrder = new ArrayList<String>();
        for (Iterator<?> iterator = children.keys(); iterator.hasNext();) {
            actualOrder.add(iterator.next().toString());
        }
        assertEquals("Invalid child order", Arrays.asList("child3", "child2", "child1"), actualOrder);

        /**
 
View Full Code Here

         * testNode - child2 - child3 - child1
         */
        children = doPut("put/node_multiple_children_reorder2.json", itemsUrl(TEST_NODE)).isOk().json()
                                                                                         .getJSONObject(CHILDREN_KEY);
        actualOrder = new ArrayList<String>();
        for (Iterator<?> iterator = children.keys(); iterator.hasNext();) {
            actualOrder.add(iterator.next().toString());
        }
        assertEquals("Invalid child order", Arrays.asList("child2", "child3", "child1"), actualOrder);
    }

View Full Code Here

            // Be sure to set this property first, before the other properties in case the other properties
            // are defined only on one of the mixin types ...
            updateMixins(newNode, properties.get(MIXIN_TYPES_PROPERTY));
        }

        for (Iterator<?> iter = properties.keys(); iter.hasNext();) {
            String key = (String)iter.next();

            if (PRIMARY_TYPE_PROPERTY.equals(key) || MIXIN_TYPES_PROPERTY.equals(key)) {
                continue;
            }
View Full Code Here

    protected List<JSONChild> getChildren( JSONObject jsonNode ) throws JSONException {
        List<JSONChild> children;
        try {
            JSONObject childrenObject = jsonNode.getJSONObject(CHILD_NODE_HOLDER);
            children = new ArrayList<>(childrenObject.length());
            for (Iterator<?> iterator = childrenObject.keys(); iterator.hasNext();) {
                String childName = iterator.next().toString();
                //it is not possible to have SNS in the object form, so the index will always be 1
                children.add(new JSONChild(childName, childrenObject.getJSONObject(childName), 1));
            }
            return children;
View Full Code Here

                }
                if (child.length() > 1) {
                    logger.warn("The child object {0} has more than 1 elements, only the first one will be taken into account",
                                child);
                }
                String childName = child.keys().next().toString();
                int sns = visitedNames.containsKey(childName) ? visitedNames.get(childName) + 1 : 1;
                visitedNames.put(childName, sns);

                children.add(new JSONChild(childName, child.getJSONObject(childName), sns));
            }
View Full Code Here

            // and properties have been processed
            mixinsToRemove = updateMixins(node, properties.get(MIXIN_TYPES_PROPERTY));
        }

        // Now set all the other properties ...
        for (Iterator<?> iter = properties.keys(); iter.hasNext();) {
            String key = (String)iter.next();
            if (PRIMARY_TYPE_PROPERTY.equals(key) || MIXIN_TYPES_PROPERTY.equals(key) || CHILD_NODE_HOLDER.equals(key)) {
                continue;
            }
            setPropertyOnNode(node, key, properties.get(key));
View Full Code Here

        }

        if (j instanceof JSONObject) {
            JSONObject jo = (JSONObject) j;
            ObjectValue ov = objectVal();
            for (Iterator<String> i = jo.keys(); i.hasNext();) {
                String key = i.next();
                ov.put(key, toValue(jo.get(key)));
            }
            return ov;
        }
View Full Code Here

    public Transition parse(JSONObject json) throws JSONException {
    final int id = json.getInt("id");
        final String name = json.getString("name");
    final JSONObject fieldsObj = json.getJSONObject("fields");
    final Iterator keys = fieldsObj.keys();
    final Collection<Transition.Field> fields = Lists.newArrayList();
    while(keys.hasNext()) {
      final String fieldId = keys.next().toString();
      fields.add(transitionFieldJsonParser.parse(fieldsObj.getJSONObject(fieldId), fieldId));
    }
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.