Package com.alibaba.fastjson.parser

Examples of com.alibaba.fastjson.parser.JSONScanner.config()


        Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.00a").scanISO8601DateIfMatch());
    }

    public void test_2() throws Exception {
        JSONScanner lexer = new JSONScanner("2000-02-10T00:00:00.000");
        lexer.config(Feature.AllowISO8601DateFormat, true);
        Assert.assertEquals(true, lexer.scanISO8601DateIfMatch());
        Assert.assertEquals(JSONToken.LITERAL_ISO8601_DATE, lexer.token());
        lexer.nextToken();
        Assert.assertEquals(JSONToken.EOF, lexer.token());
    }
View Full Code Here


        Assert.assertEquals(JSONToken.EOF, lexer.token());
    }

    public void test_3() throws Exception {
        JSONScanner lexer = new JSONScanner("2000-2");
        lexer.config(Feature.AllowISO8601DateFormat, true);
        lexer.nextToken();
        Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
        lexer.nextToken();
        Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
        lexer.nextToken();
View Full Code Here

public class JSONScannerTest_singQuoteString extends TestCase {

    public void test_string() throws Exception {
        {
            JSONScanner lexer = new JSONScanner("\'中国\'");
            lexer.config(Feature.AllowSingleQuotes, true);
            lexer.nextToken();
            Assert.assertEquals("中国", lexer.stringVal());
        }
        {
            JSONScanner lexer = new JSONScanner("'中国\t\\'\\\"'");
View Full Code Here

            lexer.nextToken();
            Assert.assertEquals("中国", lexer.stringVal());
        }
        {
            JSONScanner lexer = new JSONScanner("'中国\t\\'\\\"'");
            lexer.config(Feature.AllowSingleQuotes, true);
            lexer.nextToken();
            Assert.assertEquals("中国\t'\"", lexer.stringVal());
        }
        {
            JSONScanner lexer = new JSONScanner("\'中国\tV5\'");
View Full Code Here

            lexer.nextToken();
            Assert.assertEquals("中国\t'\"", lexer.stringVal());
        }
        {
            JSONScanner lexer = new JSONScanner("\'中国\tV5\'");
            lexer.config(Feature.AllowSingleQuotes, true);
            lexer.nextToken();
            Assert.assertEquals("中国\tV5", lexer.stringVal());
        }

        StringBuilder buf = new StringBuilder();
View Full Code Here

        buf.append('\u2001');

        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);
        lexer.config(Feature.AllowSingleQuotes, true);
        lexer.nextToken();

        Assert.assertEquals(0, lexer.pos());

        String stringVal = lexer.stringVal();
View Full Code Here

        buf.append('\'');

        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length());
        lexer.config(Feature.AllowSingleQuotes, true);
        lexer.nextToken();

        Assert.assertEquals(0, lexer.pos());

        String stringVal = lexer.stringVal();
View Full Code Here

        buf.append('\'');

        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length());
        lexer.config(Feature.AllowSingleQuotes, true);
        lexer.nextToken();

        Assert.assertEquals(0, lexer.pos());

        String stringVal = lexer.stringVal();
View Full Code Here

        buf.append('\'');

        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length());
        lexer.config(Feature.AllowSingleQuotes, true);
        lexer.nextToken();

        Assert.assertEquals(0, lexer.pos());

        String stringVal = lexer.stringVal();
View Full Code Here

    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSONScanner lexer = new JSONScanner("'k");
            lexer.config(Feature.AllowSingleQuotes, true);
            lexer.nextToken();
        } catch (JSONException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
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.