Package org.apache.sling.commons.json.util

Examples of org.apache.sling.commons.json.util.TestJSONObject


        assertEquals("[42]", renderer.prettyPrint(ja, renderer.options()));
    }
   
    @Test
    public void testDefaultArrayOutput() throws JSONException {
        final JSONObject jo = new TestJSONObject();
        final String pp = renderer.prettyPrint(jo.getJSONArray("array"), renderer.options());
        final DespacedRendering r = new DespacedRendering("{array:" + pp + "}");
        r.expect("[true,_hello_,52,212]");
    }
View Full Code Here


        r.expect("[true,_hello_,52,212]");
    }
   
    @Test
    public void testArraysPrettyPrint() throws JSONException {
        final JSONObject jo = new TestJSONObject();
       
        // Verify that we get an array for children, by re-parsing the output
        final String json = renderer.prettyPrint(jo, renderer.options().withArraysForChildren(true));
        final JSONObject copy = new JSONObject(json);
        final JSONArray a = copy.getJSONArray(JSONRenderer.Options.DEFAULT_CHILDREN_KEY);
View Full Code Here

        assertEquals(expected, str);
    }
   
    @Test
    public void testCustomNamesArraysPrettyPrint() throws JSONException {
        final JSONObject jo = new TestJSONObject();
        final JSONRenderer.Options opt = renderer.options();
        opt.withArraysForChildren(true).withIndent(2).withChildrenKey("KIDS").withChildNameKey("KID.NAME");
        final DespacedRendering r = new DespacedRendering(renderer.prettyPrint(jo, opt));
        r.expect(
                "-nl-_string_:_thisstring_,-nl-_int_:12,-nl-_long_:42,-nl-_boolean_:true,",
View Full Code Here

                );
    }   
   
    @Test
    public void testIndentedArraysPrettyPrint() throws JSONException {
        final JSONObject jo = new TestJSONObject();
        final JSONRenderer.Options opt = renderer.options().withArraysForChildren(true).withIndent(2);
        final DespacedRendering r = new DespacedRendering(renderer.prettyPrint(jo, opt));
        r.expect(
                "-nl-_string_:_thisstring_,-nl-_int_:12,-nl-_long_:42,-nl-_boolean_:true,",
                "_array_:[-nl-true,-nl-_hello_,-nl-52,-nl-212-nl-]-nl-,",
View Full Code Here

        }
    }
   
    @Before
    public void setup() throws JSONException {
        j = new TestJSONObject();
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.commons.json.util.TestJSONObject

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.