Package com.alibaba.fastjson.parser

Examples of com.alibaba.fastjson.parser.JSONScanner


        JSONScanner lexer = new JSONScanner("true\ba");
        lexer.scanTrue();
    }

    public void test_scan_false_14() throws Exception {
        JSONScanner lexer = new JSONScanner("true}");
        lexer.scanTrue();
    }
View Full Code Here


        Assert.assertEquals(1F, obj.getValue());
    }

    public void test_isBlank() throws Exception {
        String text = "   {\"value\":1.0}";
        Assert.assertTrue(!new JSONScanner(text).isBlankInput());
    }
View Full Code Here

import com.alibaba.fastjson.parser.JSONToken;

public class JSONScannerTest_ident extends TestCase {

    public void test_true() throws Exception {
        JSONScanner lexer = new JSONScanner("true");
        lexer.scanIdent();
        Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }
View Full Code Here

        lexer.scanIdent();
        Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }

    public void test_false() throws Exception {
        JSONScanner lexer = new JSONScanner("false");
        lexer.scanIdent();
        Assert.assertEquals(JSONToken.FALSE, lexer.token());
    }
View Full Code Here

        lexer.scanIdent();
        Assert.assertEquals(JSONToken.FALSE, lexer.token());
    }

    public void test_null() throws Exception {
        JSONScanner lexer = new JSONScanner("null");
        lexer.scanIdent();
        Assert.assertEquals(JSONToken.NULL, lexer.token());
    }
View Full Code Here

        lexer.scanIdent();
        Assert.assertEquals(JSONToken.NULL, lexer.token());
    }

    public void test_new() throws Exception {
        JSONScanner lexer = new JSONScanner("new");
        lexer.scanIdent();
        Assert.assertEquals(JSONToken.NEW, lexer.token());
    }
View Full Code Here

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

    public void test_Date() throws Exception {
        String text = "Date";
        JSONScanner lexer = new JSONScanner(text);
        lexer.scanIdent();
        Assert.assertEquals(JSONToken.IDENTIFIER, lexer.token());
        Assert.assertEquals(text, lexer.stringVal());
    }
View Full Code Here

public class LexerTest extends TestCase {

    public void test_float() throws Exception {
        String text = "123456789.0123";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextToken();
        BigDecimal decimalValue = lexer.decimalValue();
        Assert.assertEquals(new BigDecimal("123456789.0123"), decimalValue);

    }
View Full Code Here

    }

    public void test_string() throws Exception {
        {
            JSONScanner lexer = new JSONScanner("\"中国\"");
            lexer.nextToken();
            Assert.assertEquals("中国", lexer.stringVal());
        }
        {
            JSONScanner lexer = new JSONScanner("\"中国\t\"");
            lexer.nextToken();
            Assert.assertEquals("中国\t", lexer.stringVal());
        }
        {
            JSONScanner lexer = new JSONScanner("\"中国\tV5\"");
            lexer.nextToken();
            Assert.assertEquals("中国\tV5", lexer.stringVal());
        }

        StringBuilder buf = new StringBuilder();

        buf.append('"');
        buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
        buf.append('"');
        buf.append('\u2001');

        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);
        lexer.nextToken();

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

        String stringVal = lexer.stringVal();

        Assert.assertEquals("\"\\\\/\\b\\f\\n\\r\\t中\"", JSON.toJSONString(stringVal));

    }
View Full Code Here

        }
        buf.append('"');

        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length());
        lexer.nextToken();

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

        lexer.stringVal();

    }
View Full Code Here

TOP

Related Classes of com.alibaba.fastjson.parser.JSONScanner

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.