use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class JavaBeanSerializerTest method test_1_s.
public void test_1_s() throws Exception {
SerializeWriter out = new SerializeWriter();
B a = new B();
a.getL0().add("A");
a.getL0().add("B");
JavaBeanSerializer serializer = new JavaBeanSerializer(B.class);
serializer.write(new JSONSerializer(out), a, null, null, 0);
Assert.assertEquals("{\"l0\":[\"A\",\"B\"],\"l1\":[]}", out.toString());
}
use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class JavaBeanSerializerTest method test_3_s.
public void test_3_s() throws Exception {
SerializeWriter out = new SerializeWriter();
JavaBeanSerializer serializer = new JavaBeanSerializer(F.class);
serializer.write(new JSONSerializer(out), new F(null), null, null, 0);
Assert.assertEquals("{}", out.toString());
}
use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class ListSerializerTest method test_8_s.
public void test_8_s() throws Exception {
SerializeWriter out = new SerializeWriter(SerializerFeature.WriteClassName);
ListSerializer listSerializer = new ListSerializer();
List<Object> list = new ArrayList<Object>();
list.add(1L);
list.add(1453964515792017682L);
listSerializer.write(new JSONSerializer(out), list, null, null, 0);
Assert.assertEquals("[1L,1453964515792017682L]", out.toString());
}
use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class ListSerializerTest method test_2_s.
public void test_2_s() throws Exception {
SerializeWriter out = new SerializeWriter();
ListSerializer listSerializer = new ListSerializer();
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());
}
use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class ListSerializerTest method test_7_s.
public void test_7_s() throws Exception {
SerializeWriter out = new SerializeWriter(SerializerFeature.BrowserCompatible, SerializerFeature.WriteClassName);
ListSerializer listSerializer = new ListSerializer();
List<Object> list = new ArrayList<Object>();
list.add(1L);
list.add(1453964515792017682L);
listSerializer.write(new JSONSerializer(out), list, null, null, 0);
Assert.assertEquals("[1L,1453964515792017682L]", out.toString());
}
Aggregations