Search in sources :

Example 46 with JSONScanner

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

the class JSONScannerTest_symbol method test_7.

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

Example 47 with JSONScanner

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

the class JSONScannerTest_symbol method test_3.

public void test_3() 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 48 with JSONScanner

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

the class JSONScannerTest_symbol method test_9.

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

Example 49 with JSONScanner

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

the class JSONScannerTest_int method test_parse_long_2.

public void test_parse_long_2() throws Exception {
    System.out.println(System.currentTimeMillis());
    JSONScanner lexer = new JSONScanner(Long.toString(Integer.MIN_VALUE));
    lexer.scanNumber();
    Assert.assertEquals(new Integer(Integer.MIN_VALUE), (Integer) lexer.integerValue());
    Assert.assertEquals(Integer.MIN_VALUE, lexer.intValue());
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Example 50 with JSONScanner

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

the class JSONScannerTest_int method ftest_parse_long_1.

public void ftest_parse_long_1() throws Exception {
    System.out.println(System.currentTimeMillis());
    JSONScanner lexer = new JSONScanner(Integer.toString(Integer.MAX_VALUE));
    lexer.scanNumber();
    Assert.assertEquals(new Integer(Integer.MAX_VALUE), (Integer) lexer.integerValue());
    Assert.assertEquals(Integer.MAX_VALUE, lexer.intValue());
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Aggregations

JSONScanner (com.alibaba.fastjson.parser.JSONScanner)179 JSONException (com.alibaba.fastjson.JSONException)37 SymbolTable (com.alibaba.fastjson.parser.SymbolTable)15 JSONReader (com.alibaba.fastjson.JSONReader)11 ParseException (java.text.ParseException)5 BigInteger (java.math.BigInteger)3 DateFormat (java.text.DateFormat)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Date (java.util.Date)3 JSONLexer (com.alibaba.fastjson.parser.JSONLexer)2 JSONObject (com.alibaba.fastjson.JSONObject)1 AccessibleObject (java.lang.reflect.AccessibleObject)1 BigDecimal (java.math.BigDecimal)1 AccessControlException (java.security.AccessControlException)1 Calendar (java.util.Calendar)1