Search in sources :

Example 6 with CollectionCodec

use of com.alibaba.fastjson.serializer.CollectionCodec in project fastjson by alibaba.

the class CollectionSerializerTest method test_2_s.

public void test_2_s() throws Exception {
    SerializeWriter out = new SerializeWriter();
    CollectionCodec listSerializer = new CollectionCodec();
    List<Object> list = new ArrayList<Object>();
    list.add(1);
    list.add(2);
    listSerializer.write(new JSONSerializer(out), list, null, null, 0);
    Assert.assertEquals("[1,2]", out.toString());
}
Also used : SerializeWriter(com.alibaba.fastjson.serializer.SerializeWriter) CollectionCodec(com.alibaba.fastjson.serializer.CollectionCodec) ArrayList(java.util.ArrayList) JSONSerializer(com.alibaba.fastjson.serializer.JSONSerializer)

Aggregations

CollectionCodec (com.alibaba.fastjson.serializer.CollectionCodec)6 JSONSerializer (com.alibaba.fastjson.serializer.JSONSerializer)6 SerializeWriter (com.alibaba.fastjson.serializer.SerializeWriter)6 ArrayList (java.util.ArrayList)4