use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.
the class NumberFieldTest method test_codec_2_no_asm.
public void test_codec_2_no_asm() throws Exception {
V0 v = new V0();
v.setValue(Long.MAX_VALUE);
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
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_3_asm.
public void test_codec_3_asm() throws Exception {
V0 v = new V0();
v.setValue(new BigDecimal("3.2"));
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(true);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
Assert.assertEquals("{\"value\":3.2}", text);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(new BigDecimal("3.2"), v1.getValue());
}
use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.
the class ObjectFieldTest method test_codec_null.
public void test_codec_null() throws Exception {
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
{
V0 v = new V0();
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());
}
{
V0 v = new V0();
v.setValue(Integer.valueOf(123));
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
Assert.assertEquals("{\"value\":123}", 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 PatternFieldTest method test_codec_null.
public void test_codec_null() throws Exception {
User user = new User();
user.setValue(null);
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(user, mapping, SerializerFeature.WriteMapNullValue);
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.
the class PatternFieldTest method test_codec.
public void test_codec() throws Exception {
User user = new User();
user.setValue(Pattern.compile("."));
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(user, mapping, SerializerFeature.WriteMapNullValue);
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue().pattern(), user.getValue().pattern());
}
Aggregations