use of com.alibaba.fastjson.JSONReader 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.JSONReader in project fastjson by alibaba.
the class JSONReader_error method test_0.
public void test_0() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[]"));
Exception error = null;
try {
reader.hasNext();
} catch (Exception e) {
error = e;
}
Assert.assertNotNull(error);
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReader_top method test_int.
public void test_int() throws Exception {
JSONReader reader = new JSONReader(new StringReader("123"));
Assert.assertEquals(new Integer(123), reader.readInteger());
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReaderTest_array_object_2 method test_read.
public void test_read() throws Exception {
JSONReader reader = new JSONReader(new StringReader(text));
reader.startArray();
int count = 0;
while (reader.hasNext()) {
reader.startObject();
reader.endObject();
count++;
}
Assert.assertEquals(10, count);
reader.endArray();
reader.close();
}
use of com.alibaba.fastjson.JSONReader 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();
}
Aggregations