Search in sources :

Example 6 with SymbolTable

use of com.alibaba.fastjson.parser.SymbolTable in project fastjson by alibaba.

the class JSONScannerTest_symbol method test_4.

public void test_4() throws Exception {
    SymbolTable symbolTable = new SymbolTable(512);
    JSONScanner lexer = new JSONScanner("\"nick \\/name\"");
    String symbol = lexer.scanSymbol(symbolTable, '"');
    Assert.assertTrue("nick /name" == symbol);
    lexer.close();
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner) SymbolTable(com.alibaba.fastjson.parser.SymbolTable)

Example 7 with SymbolTable

use of com.alibaba.fastjson.parser.SymbolTable in project fastjson by alibaba.

the class JSONScannerTest_symbol method test_10.

public void test_10() throws Exception {
    SymbolTable symbolTable = new SymbolTable(512);
    JSONScanner lexer = new JSONScanner("\"nick \\t name\"");
    String symbol = lexer.scanSymbol(symbolTable, '"');
    Assert.assertTrue("nick \t name" == symbol);
    lexer.close();
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner) SymbolTable(com.alibaba.fastjson.parser.SymbolTable)

Example 8 with SymbolTable

use of com.alibaba.fastjson.parser.SymbolTable in project fastjson by alibaba.

the class JSONScannerTest_symbol method test_error_2.

public void test_error_2() throws Exception {
    JSONException error = null;
    try {
        SymbolTable symbolTable = new SymbolTable(512);
        JSONScanner lexer = new JSONScanner("\"name");
        lexer.scanSymbol(symbolTable, '"');
        lexer.close();
    } catch (JSONException e) {
        error = e;
    }
    Assert.assertNotNull(error);
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner) JSONException(com.alibaba.fastjson.JSONException) SymbolTable(com.alibaba.fastjson.parser.SymbolTable)

Example 9 with SymbolTable

use of com.alibaba.fastjson.parser.SymbolTable in project fastjson by alibaba.

the class JSONScannerTest_symbol method test_1.

public void test_1() throws Exception {
    SymbolTable symbolTable = new SymbolTable(512);
    JSONScanner lexer = new JSONScanner("\"nick name\"");
    String symbol = lexer.scanSymbol(symbolTable, '"');
    Assert.assertTrue("nick name".equals(symbol));
    lexer.close();
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner) SymbolTable(com.alibaba.fastjson.parser.SymbolTable)

Example 10 with SymbolTable

use of com.alibaba.fastjson.parser.SymbolTable in project fastjson by alibaba.

the class JSONScannerTest_symbol method test_11.

public void test_11() throws Exception {
    SymbolTable symbolTable = new SymbolTable(512);
    JSONScanner lexer = new JSONScanner("\"nick \\u4e2d name\"");
    String symbol = lexer.scanSymbol(symbolTable, '"');
    Assert.assertTrue("nick δΈ­ name" == symbol);
    lexer.close();
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner) SymbolTable(com.alibaba.fastjson.parser.SymbolTable)

Aggregations

SymbolTable (com.alibaba.fastjson.parser.SymbolTable)16 JSONScanner (com.alibaba.fastjson.parser.JSONScanner)15 JSONException (com.alibaba.fastjson.JSONException)2 CharsToNameCanonicalizer (com.fasterxml.jackson.core.sym.CharsToNameCanonicalizer)1