Search in sources :

Example 21 with JSONScanner

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

the class JSONScannerTest__nextToken method test_next_13.

public void test_next_13() throws Exception {
    String text = "\n\r\t\f\b :\n\r\t\f\b ";
    JSONScanner lexer = new JSONScanner(text);
    lexer.nextTokenWithColon(JSONToken.LBRACKET);
    Assert.assertEquals(JSONToken.EOF, lexer.token());
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Example 22 with JSONScanner

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

the class JSONScannerTest__nextToken method test_next_2.

public void test_next_2() throws Exception {
    String text = "{";
    JSONScanner lexer = new JSONScanner(text);
    lexer.nextToken(JSONToken.LITERAL_INT);
    Assert.assertEquals(JSONToken.LBRACE, lexer.token());
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Example 23 with JSONScanner

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

the class JSONReaderTest_object_int method test_read_1.

public void test_read_1() throws Exception {
    String text = "[{},{},{},{},{} ,{},{},{},{},{}]";
    JSONReader reader = new JSONReader(new JSONScanner(text));
    reader.startArray();
    int count = 0;
    while (reader.hasNext()) {
        reader.readObject();
        count++;
    }
    Assert.assertEquals(10, count);
    reader.endArray();
    reader.close();
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner) JSONReader(com.alibaba.fastjson.JSONReader)

Example 24 with JSONScanner

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

the class JSONReaderTest_object_long method test_read_1.

public void test_read_1() throws Exception {
    JSONReader reader = new JSONReader(new JSONScanner(text));
    reader.startObject();
    int count = 0;
    while (reader.hasNext()) {
        String key = (String) reader.readObject();
        Long value = reader.readLong();
        count++;
    }
    Assert.assertEquals(10, count);
    reader.endObject();
    reader.close();
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner) JSONReader(com.alibaba.fastjson.JSONReader)

Example 25 with JSONScanner

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

the class JSONScannerTest__nextToken method test_next.

public void test_next() throws Exception {
    String text = "\"aaa\"";
    JSONScanner lexer = new JSONScanner(text);
    lexer.nextToken(JSONToken.LITERAL_INT);
    Assert.assertEquals(JSONToken.LITERAL_STRING, lexer.token());
}
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