use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.
the class LongArrayFieldTest method test_codec_null_1.
public void test_codec_null_1() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty);
Assert.assertEquals("{\"value\":[]}", text);
}
use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.
the class LongFieldTest method test_codec_null.
public void test_codec_null() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
Assert.assertEquals("{\"value\":null}", text);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue(), v.getValue());
}
use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.
the class NumberFieldTest method test_codec_2_asm.
public void test_codec_2_asm() throws Exception {
V0 v = new V0();
v.setValue(Long.MAX_VALUE);
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(true);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
Assert.assertEquals("{\"value\":" + Long.MAX_VALUE + "}", text);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(new Long(Long.MAX_VALUE), v1.getValue());
}
use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.
the class NumberFieldTest method test_codec_null_1_asm.
public void test_codec_null_1_asm() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(true);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullNumberAsZero);
Assert.assertEquals("{\"value\":0}", text);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(Integer.valueOf(0), v1.getValue());
}
use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.
the class NumberFieldTest method test_codec_null.
public void test_codec_null() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
Assert.assertEquals("{\"value\":null}", text);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue(), v.getValue());
}
Aggregations