use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class JavaBeanSerializerTest method test_0_s.
public void test_0_s() throws Exception {
SerializeWriter out = new SerializeWriter();
A a = new A();
a.getL0().add("A");
a.getL0().add("B");
JavaBeanSerializer serializer = new JavaBeanSerializer(A.class);
serializer.write(new JSONSerializer(out), a, null, null, 0);
Assert.assertEquals("{\"l0\":[\"A\",\"B\"]}", out.toString());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class JavaBeanSerializerTest method test_error_1_s.
public void test_error_1_s() throws Exception {
JSONException error = null;
try {
SerializeWriter out = new SerializeWriter();
JavaBeanSerializer serializer = new JavaBeanSerializer(D.class);
serializer.write(new JSONSerializer(out), new D(), null, null, 0);
} catch (JSONException e) {
error = e;
}
Assert.assertNotNull(error);
}
use of com.alibaba.fastjson.serializer.SerializeWriter 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.SerializeWriter 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.SerializeWriter 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());
}
Aggregations