Package com.cumulocity.me.rest.json

Examples of com.cumulocity.me.rest.json.JSONArray


        assertThat(representation.getReferences().size()).isEqualTo(getListOfReferences().size());
    }

    private JSONArray getJsonArrayReferenceRepresentation() {
        JSONArray jsonArray = aJSONArray()
                .withPropertyBuilder(getMinimalJsonManagedObjectReferenceRepresentation())
                .withPropertyBuilder(getMinimalJsonManagedObjectReferenceRepresentation()).build();
        return jsonArray;
    }
View Full Code Here


        assertThat(representation.getManagedObjects()).isNotNull();
        assertThat(representation.getManagedObjects().size()).isEqualTo(getListOfManagedObjects().size());
    }

    private Object getJsonListManagedObjects() {
        JSONArray jsonArray = aJSONArray().withPropertyBuilder(getSampleJsonManagedObjectRepresentation())
                .withPropertyBuilder(getSampleJsonManagedObjectRepresentation()).build();
        return jsonArray;
    }
View Full Code Here

    protected Object getObject(JSONObject json, String propertyName, Class propertyType) {
        return conversionService.fromJson(json.optJSONObject(propertyName), propertyType);
    }

    protected List getList(JSONObject json, String propertyName, Class propertyElementType) {
        JSONArray jsonArray = json.optJSONArray(propertyName);
        if (jsonArray == null) {
            return null;
        }
        List list = new ArrayList();
        for (int i = 0; i < jsonArray.length(); i++) {
            list.add(conversionService.fromJson(jsonArray.getJSONObject(i), propertyElementType));
        }
        return list;
    }
View Full Code Here

        }
        return list;
    }

    protected Set getSet(JSONObject json, String propertyName, Class propertyElementType) {
        JSONArray jsonArray = json.optJSONArray(propertyName);
        if (jsonArray == null) {
            return null;
        }
        Set set = new HashSet();
        for (int i = 0; i < jsonArray.length(); i++) {
            set.add(conversionService.fromJson(jsonArray.getJSONObject(i), propertyElementType));
        }
        return set;
    }
View Full Code Here

            json.putOpt(key, getConversionService().toJson(representation));
        }
    }

    protected void putList(JSONObject json, String key, List array) {
        JSONArray jsonarray = new JSONArray();
        Iterator iterator = array.iterator();
        while (iterator.hasNext()) {
            jsonarray.put(conversionService.toJson((ResourceRepresentation) iterator.next()));
        }
        json.putOpt(key, jsonarray);
    }
View Full Code Here

        }
    }

    protected void putSet(JSONObject json, String key, Set set) {
        if (set != null) {
            JSONArray jsonarray = new JSONArray();
            Iterator iterator = set.iterator();
            while (iterator.hasNext()) {
                jsonarray.put(conversionService.toJson((ResourceRepresentation) iterator.next()));
            }
            json.putOpt(key, jsonarray);
        }
    }
View Full Code Here

        return this;
    }
   
    @Override
    protected JSONArray createDomainObject() {
        JSONArray json = new JSONArray();

        int i = 0;
        for (Object object : values) {
            json.put(i, object);
            i++;
        }

        for (AbstractObjectBuilder<?> builder : builders) {
            json.put(i, builder.build());
            i++;
        }
        return json;
    }
View Full Code Here

TOP

Related Classes of com.cumulocity.me.rest.json.JSONArray

Copyright © 2018 www.massapicom. 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.