use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class Issue72 method test_for_issue.
public void test_for_issue() throws Exception {
InputStream is = Issue72.class.getClassLoader().getResourceAsStream("issue72.json");
JSONReader reader = null;
try {
byte[] rowBatchBytes = null;
byte[] fileBatchBytes = null;
reader = new JSONReader(new InputStreamReader(is));
reader.startArray();
while (reader.hasNext()) {
if (rowBatchBytes == null) {
rowBatchBytes = reader.readObject(byte[].class);
} else if (fileBatchBytes == null) {
fileBatchBytes = reader.readObject(byte[].class);
} else {
throw new Exception("archive data json parse failed!");
}
}
reader.endArray();
} finally {
IOUtils.close(reader);
}
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReaderScannerTest_bytes method test_e.
public void test_e() throws Exception {
VO vo = new VO();
vo.setValue("ABC".getBytes("UTF-8"));
String text = JSON.toJSONString(vo);
JSONReader reader = new JSONReader(new StringReader(text));
VO vo2 = reader.readObject(VO.class);
Assert.assertEquals("ABC", new String(vo2.getValue()));
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReaderScannerTest_enum method test_e.
public void test_e() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{type:'AA'}"));
VO vo2 = reader.readObject(VO.class);
Assert.assertEquals(Type.AA, vo2.getType());
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReaderScannerTest_jsonobject method test_e.
public void test_e() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"type\\t\":'AA'}"));
JSONObject vo = new JSONObject();
reader.readObject(vo);
Assert.assertEquals("AA", vo.get("type\t"));
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReaderTest_array_array 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()) {
Object item = reader.readObject();
Assert.assertEquals(JSONArray.class, item.getClass());
count++;
}
Assert.assertEquals(10, count);
reader.endArray();
reader.close();
}
Aggregations