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());
}
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());
}
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();
}
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();
}
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());
}
Aggregations