use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class ListSerializerTest method test_4_s.
public void test_4_s() throws Exception {
SerializeWriter out = new SerializeWriter();
ListSerializer listSerializer = new ListSerializer();
List<Object> list = new ArrayList<Object>();
list.add(1L);
list.add(2L);
list.add(3L);
list.add(Collections.emptyMap());
listSerializer.write(new JSONSerializer(out), list, null, null, 0);
Assert.assertEquals("[1,2,3,{}]", out.toString());
}
use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class ListSerializerTest method test_5_s.
public void test_5_s() throws Exception {
SerializeWriter out = new SerializeWriter();
ListSerializer listSerializer = new ListSerializer();
List<Object> list = new ArrayList<Object>();
list.add(1L);
list.add(21474836480L);
list.add(null);
list.add(Collections.emptyMap());
list.add(21474836480L);
listSerializer.write(new JSONSerializer(out), list, null, null, 0);
Assert.assertEquals("[1,21474836480,null,{},21474836480]", out.toString());
}
use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class ListSerializerTest2 method test_0.
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter();
ListSerializer listSerializer = new ListSerializer();
Object[] array = new Object[] { 1, 2, 3L, 4L, 5, 6, "a" };
List<Object> list = Arrays.asList(array);
listSerializer.write(new JSONSerializer(out), list, null, null, 0);
// System.out.println(out.toString());
Assert.assertEquals("[1,2,3,4,5,6,\"a\"]", out.toString());
}
use of com.alibaba.fastjson.serializer.JSONSerializer 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.JSONSerializer 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));
}
Aggregations