Package org.json.simple

Examples of org.json.simple.JSONArray


    public static JSONArray getJSONArrayFromList(List<?> list) {
        if (list == null) {
            return null;
        }

        JSONArray result = new JSONArray();
        result.addAll(list);

        return result;
    }
View Full Code Here


        String toDiff = "+\"/b\":{}";
        String toMsg = "Add /b";
        String toRev = mk.commit("", toDiff, null, toMsg);

        JSONArray array = parseJSONArray(mk.getJournal(fromRev, toRev, "/"));
        assertEquals(2, array.size());

        JSONObject rev = getObjectArrayEntry(array, 0);
        assertPropertyExists(rev, "id", String.class);
        assertPropertyExists(rev, "ts", Long.class);
        assertPropertyValue(rev, "msg", fromMsg);
View Full Code Here

    @Test
    public void commitAddWithDiffPaths() {
        // Commit with empty path and retrieve with root path
        String rev = mk.commit("", "+\"/a\":{}", null, "");
        String journalStr = mk.getJournal(rev, rev, "/");
        JSONArray array = parseJSONArray(journalStr);
        JSONObject entry = getObjectArrayEntry(array, 0);
        String expected = "+\"/a\":{}";
        assertPropertyValue(entry, "changes", expected);

        // Commit with root path and retrieve with root path
View Full Code Here

        mk.commit("", "+\"/a\":{}", null, "");

        // Commit with empty path and retrieve with root path
        String rev = mk.commit("", "*\"/a\" : \"/b\"", null, null);
        String journalStr = mk.getJournal(rev, rev, "/");
        JSONArray array = parseJSONArray(journalStr);
        JSONObject entry = getObjectArrayEntry(array, 0);
        String expected = "*\"/a\":\"/b\"";
        assertPropertyValue(entry, "changes", expected);

        // Commit with root path and retrieve with root path
View Full Code Here

        mk.commit("", "+\"/a\":{}", null, "");

        // Commit with empty path and retrieve with root path
        String rev = mk.commit("", ">\"/a\" : \"/b\"", null, null);
        String journalStr = mk.getJournal(rev, rev, "/");
        JSONArray array = parseJSONArray(journalStr);
        JSONObject entry = getObjectArrayEntry(array, 0);
        String expected = ">\"/a\":\"/b\"";
        assertPropertyValue(entry, "changes", expected);

        // Commit with root path and retrieve with root path
View Full Code Here

        mk.commit("", "+\"/a\":{}", null, "");

        // Commit with empty path and retrieve with root path
        String rev = mk.commit("", "-\"/a\"", null, null);
        String journalStr = mk.getJournal(rev, rev, "/");
        JSONArray array = parseJSONArray(journalStr);
        JSONObject entry = getObjectArrayEntry(array, 0);
        String expected = "-\"/a\"";
        assertPropertyValue(entry, "changes", expected);

        mk.commit("", "+\"/b\":{}", null, "");
View Full Code Here

        mk.commit("", "+\"/a\":{}", null, "");

        // Commit with empty path and retrieve with root path
        String rev = mk.commit("", "^\"/a/key1\" : \"value1\"", null, null);
        String journalStr = mk.getJournal(rev, rev, "/");
        JSONArray array = parseJSONArray(journalStr);
        JSONObject entry = getObjectArrayEntry(array, 0);
        String expected = "^\"/a/key1\":\"value1\"";
        assertPropertyValue(entry, "changes", expected);

        // Commit with root path and retrieve with root path
View Full Code Here

public class MongoMKGetRevisionHistoryTest extends AbstractMongoConnectionTest {

    @Test
    public void maxEntriesZero() throws Exception {
        mk.commit("/", "+\"a\" : {}", null, null);
        JSONArray array = parseJSONArray(mk.getRevisionHistory(0, 0, "/"));
        assertEquals(0, array.size());
    }
View Full Code Here

    public void maxEntriesLimitless() throws Exception {
        int count = 10;
        for (int i = 0; i < count; i++) {
            mk.commit("/", "+\"a" + i + "\" : {}", null, null);
        }
        JSONArray array = parseJSONArray(mk.getRevisionHistory(0, -1, "/"));
        assertEquals(count + 1, array.size());
    }
View Full Code Here

        int limit = 4;

        for (int i = 0; i < count; i++) {
            mk.commit("/", "+\"a" + i + "\" : {}", null, null);
        }
        JSONArray array = parseJSONArray(mk.getRevisionHistory(0, limit, "/"));
        assertEquals(limit, array.size());
    }
View Full Code Here

TOP

Related Classes of org.json.simple.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.