本文整理汇总了Java中com.alibaba.fastjson.serializer.JavaBeanSerializer.write方法的典型用法代码示例。如果您正苦于以下问题:Java JavaBeanSerializer.write方法的具体用法?Java JavaBeanSerializer.write怎么用?Java JavaBeanSerializer.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.serializer.JavaBeanSerializer
的用法示例。
在下文中一共展示了JavaBeanSerializer.write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_0_s
import com.alibaba.fastjson.serializer.JavaBeanSerializer; //导入方法依赖的package包/类
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());
}
示例2: test_1_s
import com.alibaba.fastjson.serializer.JavaBeanSerializer; //导入方法依赖的package包/类
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());
}
示例3: test_2_s
import com.alibaba.fastjson.serializer.JavaBeanSerializer; //导入方法依赖的package包/类
public void test_2_s() throws Exception {
SerializeWriter out = new SerializeWriter();
JavaBeanSerializer serializer = new JavaBeanSerializer(F.class);
serializer.write(new JSONSerializer(out), new F(new E(123)), null, null, 0);
Assert.assertEquals("{\"e\":{\"id\":123}}", out.toString());
}
示例4: test_3_s
import com.alibaba.fastjson.serializer.JavaBeanSerializer; //导入方法依赖的package包/类
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());
}
示例5: test_error_s
import com.alibaba.fastjson.serializer.JavaBeanSerializer; //导入方法依赖的package包/类
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);
}
示例6: test_error_1_s
import com.alibaba.fastjson.serializer.JavaBeanSerializer; //导入方法依赖的package包/类
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);
}