Package cc.plural.jsonij

Examples of cc.plural.jsonij.StringJSONReader


     * Test of getStringReader method, of class JSONReader.
     */
    @Test
    public void testStringJSONReader() throws IOException, ParserException {
        System.out.println("getStringReader");
        StringJSONReader instance = new StringJSONReader(TEST_STRING1);
        char c;
        c = (char) instance.peek();
        assertEquals('T', c);
        c = (char) instance.read();
        assertEquals('T', c);
        c = (char) instance.peek();
        assertEquals('h', c);
        c = (char) instance.read();
        assertEquals('h', c);
        c = (char) instance.peek();
        assertEquals('i', c);
        c = (char) instance.read();
        assertEquals('i', c);
        c = (char) instance.peek();
        assertEquals('s', c);
        c = (char) instance.read();
        assertEquals('s', c);

        c = (char) instance.peek();
        assertEquals('i', c);
        c = (char) instance.read();
        assertEquals('i', c);

        c = (char) instance.read();
        assertEquals('s', c);
       
        ReaderParser stringReaderInstance = instance.getStringReader();
        c = (char) stringReaderInstance.peek();
        assertEquals(' ', c);
        c = (char) stringReaderInstance.read();
        assertEquals(' ', c);
        assertEquals('\t', stringReaderInstance.peek());
        assertEquals('\t', stringReaderInstance.read());
        assertEquals(' ', stringReaderInstance.read());
        assertEquals('a', stringReaderInstance.peek());
        assertEquals('a', stringReaderInstance.read());
        stringReaderInstance.close();
        assertEquals('s', instance.read());
        assertEquals('t', instance.read());
    }
View Full Code Here


     * @throws ParserException
     */
    @Test
    public void testParseString1() throws IOException, ParserException {
        String testString = "\"John\"";
        JSONReader target = new StringJSONReader(testString);
        JSON.String value = parser.parseString(target);
        if (!value.toString().equals("John")) {
            fail();
        }
    }
View Full Code Here

    }

    @Test
    public void testStringDecodeEncode() throws IOException, ParserException {
        String jsonString = "\"John\\tMarsden\"";
        JSONReader target = new StringJSONReader(jsonString);
        JSON.String value = parser.parseString(target);
        assertEquals(value.toString(),"John\tMarsden");
        assertEquals(value.toJSON(),"\"John\\tMarsden\"");

        jsonString = "\"\\u5b66\"";
        target = new StringJSONReader(jsonString);
        value = parser.parseString(target);
        assertEquals(value.toString(),"\u5b66");
        assertEquals(value.toJSON(),"\"\\u5b66\"");

        jsonString = "\"\\ud801\\udc01\"";
        target = new StringJSONReader(jsonString);
        value = parser.parseString(target);
        assertEquals(value.toString(),"\ud801\udc01");
        assertEquals(value.toJSON(), "\"\\ud801\\udc01\"");
    }
View Full Code Here

TOP

Related Classes of cc.plural.jsonij.StringJSONReader

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.