use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class JSONReaderTest_array_object method test_read_1.
public void test_read_1() throws Exception {
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();
}
use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class JSONScannerTest_ISO8601 method test_3.
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();
Assert.assertEquals(JSONToken.EOF, lexer.token());
}
use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class JSONScannerTest_ISO8601 method test_2.
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());
}
use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class JSONScannerTest__nextToken method test_next_1.
public void test_next_1() throws Exception {
String text = "[";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken(JSONToken.LITERAL_INT);
Assert.assertEquals(JSONToken.LBRACKET, lexer.token());
}
use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class JSONScannerTest__nextToken method test_next_7.
public void test_next_7() throws Exception {
String text = "{";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken(JSONToken.EOF);
Assert.assertEquals(JSONToken.LBRACE, lexer.token());
}
Aggregations