use of com.alibaba.fastjson.serializer.JavaBeanSerializer 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.JavaBeanSerializer 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.JavaBeanSerializer 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.JavaBeanSerializer in project fastjson by alibaba.
the class TypeUtilsTest_castToJavaBean method test_bean_3.
public void test_bean_3() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 123);
PO vo = TypeUtils.castToJavaBean(map, PO.class);
Assert.assertEquals(123, vo.id);
SerializeWriter out = new SerializeWriter();
try {
SerializeConfig config = new SerializeConfig();
JSONSerializer serializer = new JSONSerializer(out, config);
config.put(PO.class, new JavaBeanSerializer(PO.class, Collections.singletonMap("id", (String) null)));
serializer.write(vo);
Assert.assertEquals("{}", out.toString());
} finally {
out.close();
}
}
use of com.alibaba.fastjson.serializer.JavaBeanSerializer in project fastjson by alibaba.
the class JavaBeanSerializerTest method test_error_s.
public void test_error_s() throws Exception {
JSONException error = null;
try {
SerializeWriter out = new SerializeWriter();
JavaBeanSerializer serializer = new JavaBeanSerializer(C.class);
serializer.write(new JSONSerializer(out), new C(), null, null, 0);
} catch (JSONException e) {
error = e;
}
Assert.assertNotNull(error);
}
Aggregations