use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class ListSerializerTest3 method test_2.
public void test_2() throws Exception {
SerializeWriter out = new SerializeWriter();
ListSerializer listSerializer = new ListSerializer();
LinkedList<Object> list = new LinkedList<Object>();
for (int i = 0; i < 100000; i++) {
list.add(i);
}
long start = System.currentTimeMillis();
listSerializer.write(new JSONSerializer(out), list, null, null, 0);
long end = System.currentTimeMillis();
System.out.println("linkedList time: " + (end - start));
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class ListSerializerTest3 method test_1.
public void test_1() throws Exception {
SerializeWriter out = new SerializeWriter();
ListSerializer listSerializer = new ListSerializer();
ArrayList<Object> list = new ArrayList<Object>();
for (int i = 0; i < 100000; i++) {
list.add(i);
}
long start = System.currentTimeMillis();
listSerializer.write(new JSONSerializer(out), list, null, null, 0);
long end = System.currentTimeMillis();
System.out.println("arrayList time: " + (end - start));
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class MapSerializerTest method test_singleton_1.
public void test_singleton_1() throws Exception {
SerializeWriter out = new SerializeWriter();
MapSerializer mapSerializer = new MapSerializer();
mapSerializer.write(new JSONSerializer(out), Collections.singletonMap("A", 1), null, null, 0);
Assert.assertEquals("{\"A\":1}", out.toString());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class ByteArraySerializerTest method test_1.
public void test_1() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.writeByteArray(new byte[] { 1, 2, 3 });
Assert.assertEquals("\"AQID\"", out.toString());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class CollectionSerializerTest method test_0.
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter();
CollectionCodec listSerializer = new CollectionCodec();
listSerializer.write(new JSONSerializer(out), Collections.EMPTY_LIST, null, null, 0);
Assert.assertEquals("[]", out.toString());
}
Aggregations