Package org.codehaus.jettison.json

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


        Assert.assertNotNull(json);
        Assert.assertTrue(json.has(GraphSONTokens._ID));
        Assert.assertEquals(1, json.optInt(GraphSONTokens._ID));
        Assert.assertTrue(json.has(GraphSONTokens._TYPE));
        Assert.assertEquals("vertex", json.optString(GraphSONTokens._TYPE));
        Assert.assertEquals("marko", json.optString("name"));
    }

    @Test
    public void jsonFromElementVertexCompactIdOnlyAsInclude() throws JSONException {
View Full Code Here


        Assert.assertNotNull(json);
        Assert.assertTrue(json.has(GraphSONTokens._ID));
        Assert.assertEquals(1, json.optInt(GraphSONTokens._ID));
        Assert.assertTrue(json.has(GraphSONTokens._TYPE));
        Assert.assertEquals("vertex", json.optString(GraphSONTokens._TYPE));
        Assert.assertEquals("marko", json.optString("name"));
    }

    @Test
    public void jsonFromElementVertexCompactIdOnlyAsInclude() throws JSONException {
        Vertex v = this.graph.addVertex(1);
View Full Code Here

        Assert.assertNotNull(json);
        Assert.assertTrue(json.has(GraphSONTokens._ID));
        Assert.assertEquals(1, json.optInt(GraphSONTokens._ID));
        Assert.assertTrue(json.has("keyString"));
        Assert.assertEquals("string", json.optString("keyString"));
        Assert.assertTrue(json.has("keyLong"));
        Assert.assertEquals(1L, json.optLong("keyLong"));
        Assert.assertTrue(json.has("keyInt"));
        Assert.assertEquals(2, json.optInt("keyInt"));
        Assert.assertTrue(json.has("keyFloat"));
View Full Code Here

        Assert.assertTrue(json.has("keyMap"));

        JSONObject mapAsJSON = json.optJSONObject("keyMap");
        Assert.assertNotNull(mapAsJSON);
        Assert.assertTrue(mapAsJSON.has("this"));
        Assert.assertEquals("some", mapAsJSON.optString("this"));
        Assert.assertTrue(mapAsJSON.has("that"));
        Assert.assertEquals(1, mapAsJSON.optInt("that"));
    }

    @Test
View Full Code Here

        JSONArray jsonArray = json.getJSONObject("keyList").getJSONArray(GraphSONTokens.VALUE);
        Assert.assertNotNull(jsonArray);
        JSONObject jsonObjectListFirst = jsonArray.getJSONObject(0);
        Assert.assertTrue(jsonObjectListFirst.isNull(GraphSONTokens.VALUE));
        Assert.assertEquals(GraphSONTokens.TYPE_UNKNOWN, jsonObjectListFirst.optString(GraphSONTokens.TYPE));
    }

    @Test
    public void vertexFromJsonValid() throws IOException, JSONException {
        Graph g = new TinkerGraph();
View Full Code Here

        Assert.assertTrue(json.has("keyList"));

        JSONObject listWithTypeAsJson = json.optJSONObject("keyList");
        Assert.assertNotNull(listWithTypeAsJson);
        Assert.assertTrue(listWithTypeAsJson.has(GraphSONTokens.TYPE));
        Assert.assertEquals(GraphSONTokens.TYPE_LIST, listWithTypeAsJson.optString(GraphSONTokens.TYPE));
        Assert.assertTrue(listWithTypeAsJson.has(GraphSONTokens.VALUE));
        JSONArray listAsJSON = listWithTypeAsJson.optJSONArray(GraphSONTokens.VALUE);
        Assert.assertNotNull(listAsJSON);
        Assert.assertEquals(3, listAsJSON.length());
View Full Code Here

        for (int ix = 0; ix < listAsJSON.length(); ix++) {
            JSONObject valueAsJson = listAsJSON.optJSONObject(ix);
            Assert.assertNotNull(valueAsJson);
            Assert.assertTrue(valueAsJson.has(GraphSONTokens.TYPE));
            Assert.assertEquals(GraphSONTokens.TYPE_BOOLEAN, valueAsJson.optString(GraphSONTokens.TYPE));
            Assert.assertTrue(valueAsJson.has(GraphSONTokens.VALUE));
            Assert.assertEquals(true, valueAsJson.optBoolean(GraphSONTokens.VALUE));
        }
    }
View Full Code Here

        Assert.assertTrue(json.has("keyList"));

        JSONObject listWithTypeAsJson = json.optJSONObject("keyList");
        Assert.assertNotNull(listWithTypeAsJson);
        Assert.assertTrue(listWithTypeAsJson.has(GraphSONTokens.TYPE));
        Assert.assertEquals(GraphSONTokens.TYPE_LIST, listWithTypeAsJson.optString(GraphSONTokens.TYPE));
        Assert.assertTrue(listWithTypeAsJson.has(GraphSONTokens.VALUE));
        JSONArray listAsJSON = listWithTypeAsJson.optJSONArray(GraphSONTokens.VALUE);
        Assert.assertNotNull(listAsJSON);
        Assert.assertEquals(3, listAsJSON.length());
View Full Code Here

        for (int ix = 0; ix < listAsJSON.length(); ix++) {
            JSONObject valueAsJson = listAsJSON.optJSONObject(ix);
            Assert.assertNotNull(valueAsJson);
            Assert.assertTrue(valueAsJson.has(GraphSONTokens.TYPE));
            Assert.assertEquals(GraphSONTokens.TYPE_LONG, valueAsJson.optString(GraphSONTokens.TYPE));
            Assert.assertTrue(valueAsJson.has(GraphSONTokens.VALUE));
            Assert.assertEquals(1000L, valueAsJson.optLong(GraphSONTokens.VALUE));
        }
    }
View Full Code Here

        Assert.assertTrue(json.has("keyList"));

        JSONObject listWithTypeAsJson = json.optJSONObject("keyList");
        Assert.assertNotNull(listWithTypeAsJson);
        Assert.assertTrue(listWithTypeAsJson.has(GraphSONTokens.TYPE));
        Assert.assertEquals(GraphSONTokens.TYPE_LIST, listWithTypeAsJson.optString(GraphSONTokens.TYPE));
        Assert.assertTrue(listWithTypeAsJson.has(GraphSONTokens.VALUE));
        JSONArray listAsJSON = listWithTypeAsJson.optJSONArray(GraphSONTokens.VALUE);
        Assert.assertNotNull(listAsJSON);
        Assert.assertEquals(3, listAsJSON.length());
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.