APISonar


com.amazon.ion.system.IonTextWriterBuilder.json

> com > amazon > ion > system > IonTextWriterBuilder > json
com APIs amazon APIs ion APIs system APIs IonTextWriterBuilder APIs json APIs

Example 1
public void testJsonLongStrings()
        throws Exception
    {
        options = IonTextWriterBuilder.json();
        options.setLongStringThreshold(5);

        IonDatagram dg = system().newDatagram();
        dg.add().newString("hello");
        dg.add().newString("hello!");
        dg.add().newString("goodbye");
        dg.add().newString("what's\nup\ndoc");

        expectRendering("\"hello\" '''hello!''' \"goodbye\" '''what\\'s\nup\ndoc'''",
                        dg);
    }
Example 2
public void testJsonSystemMinimization()
        throws Exception
    {
        SymbolTable fred1 = Symtabs.register("fred",   1, catalog());

        options = IonTextWriterBuilder.json();
        iw = makeWriter(fred1);
        iw.writeSymbol(ION_1_0);
        iw.writeSymbol("fred_1");
        iw.writeSymbol(ION_1_0);
        iw.writeSymbol(ION_1_0);
        iw.writeSymbol("fred_1");

        assertEquals("\"fred_1\" \"fred_1\"", outputString());
    }