use of com.alibaba.fastjson.parser.JSONReaderScanner in project fastjson by alibaba.
the class JSONReaderScannerTest__entity_double method test_scanFloat.
public void test_scanFloat() throws Exception {
StringBuffer buf = new StringBuffer();
buf.append('[');
for (int i = 0; i < 1024; ++i) {
if (i != 0) {
buf.append(',');
}
buf.append("{\"id\":" + i + ".0}");
}
buf.append(']');
Reader reader = new StringReader(buf.toString());
JSONReaderScanner scanner = new JSONReaderScanner(reader);
DefaultJSONParser parser = new DefaultJSONParser(scanner);
List<VO> array = parser.parseArray(VO.class);
for (int i = 0; i < array.size(); ++i) {
Assert.assertTrue((double) i == array.get(i).getId());
}
parser.close();
}
use of com.alibaba.fastjson.parser.JSONReaderScanner in project fastjson by alibaba.
the class JSONReaderScannerTest__entity_float method test_scanFloat.
public void test_scanFloat() throws Exception {
StringBuffer buf = new StringBuffer();
buf.append('[');
for (int i = 0; i < 1024; ++i) {
if (i != 0) {
buf.append(',');
}
buf.append("{\"id\":" + i + ".0}");
}
buf.append(']');
Reader reader = new StringReader(buf.toString());
JSONReaderScanner scanner = new JSONReaderScanner(reader);
DefaultJSONParser parser = new DefaultJSONParser(scanner);
List<VO> array = parser.parseArray(VO.class);
for (int i = 0; i < array.size(); ++i) {
Assert.assertTrue((float) i == array.get(i).getId());
}
parser.close();
}
use of com.alibaba.fastjson.parser.JSONReaderScanner in project fastjson by alibaba.
the class JSONReaderScannerTest__entity_int method test_scanInt.
public void test_scanInt() throws Exception {
StringBuffer buf = new StringBuffer();
buf.append('[');
for (int i = 0; i < 1024; ++i) {
if (i != 0) {
buf.append(',');
}
buf.append("{\"id\":" + i + "}");
}
buf.append(']');
Reader reader = new StringReader(buf.toString());
JSONReaderScanner scanner = new JSONReaderScanner(reader);
DefaultJSONParser parser = new DefaultJSONParser(scanner);
List<VO> array = parser.parseArray(VO.class);
for (int i = 0; i < array.size(); ++i) {
Assert.assertEquals(i, array.get(i).getId());
}
}
use of com.alibaba.fastjson.parser.JSONReaderScanner in project fastjson by alibaba.
the class JSONReaderScannerTest_type method test_true.
@SuppressWarnings("rawtypes")
public void test_true() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"@type\":\"java.util.LinkedHashMap\",\"name\":\"张三\"}"));
LinkedHashMap json = (LinkedHashMap) parser.parse();
Assert.assertEquals("张三", json.get("name"));
parser.close();
}
use of com.alibaba.fastjson.parser.JSONReaderScanner in project fastjson by alibaba.
the class JSONReaderScannerTest method test_doubleQuote_2.
public void test_doubleQuote_2() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{name:\"张三\\'\\n\\r\\\"\"}"));
JSONObject json = parser.parseObject();
Assert.assertEquals("张三\'\n\r\"", json.get("name"));
parser.close();
}
Aggregations