Code example for JsonArray

Methods: add

0
        assertEquals("Bond, James Bond", result.content(".a"));
        assertEquals("James Bond", result.content(".a a"));
        assertEquals("#", result.attr(".a a", "href"));
 
        // Contents 
        JsonArray list = new JsonArray();
        list.add(new JsonPrimitive(1));
        list.add(new JsonPrimitive(2));
        list.add(new JsonPrimitive(3));
 
        data = new JsonObject();
        data.add("list", list);
 
        template = Utils.readFile("src/main/webapp/template/dot/dummy-template-8.html");
        result = helper.doTemplateAsResult(template, data);
        List<String> contents = result.contents("li");
        assertEquals(3, contents.size());
        assertEquals("1", contents.get(0));
        assertEquals("2", contents.get(1));
        assertEquals("3", contents.get(2));