Search in sources :

Example 41 with SerializeConfig

use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.

the class TimeZoneFieldTest 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());
}
Also used : SerializeConfig(com.alibaba.fastjson.serializer.SerializeConfig)

Example 42 with SerializeConfig

use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.

the class URLFieldTest method test_codec.

public void test_codec() throws Exception {
    User user = new User();
    user.setValue(new URL("http://code.alibaba-tech.com"));
    SerializeConfig mapping = new SerializeConfig();
    mapping.setAsmEnable(false);
    String text = JSON.toJSONString(user, mapping, SerializerFeature.WriteMapNullValue);
    System.out.println(text);
    User user1 = JSON.parseObject(text, User.class);
    Assert.assertEquals(user1.getValue().toString(), user.getValue().toString());
}
Also used : SerializeConfig(com.alibaba.fastjson.serializer.SerializeConfig) URL(java.net.URL)

Example 43 with SerializeConfig

use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.

the class URLFieldTest 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());
}
Also used : SerializeConfig(com.alibaba.fastjson.serializer.SerializeConfig)

Example 44 with SerializeConfig

use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.

the class UUIDFieldTest 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());
}
Also used : SerializeConfig(com.alibaba.fastjson.serializer.SerializeConfig)

Example 45 with SerializeConfig

use of com.alibaba.fastjson.serializer.SerializeConfig in project fastjson by alibaba.

the class UUIDFieldTest method test_codec.

public void test_codec() throws Exception {
    User user = new User();
    user.setValue(UUID.randomUUID());
    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());
}
Also used : SerializeConfig(com.alibaba.fastjson.serializer.SerializeConfig)

Aggregations

SerializeConfig (com.alibaba.fastjson.serializer.SerializeConfig)191 Date (java.util.Date)16 ParserConfig (com.alibaba.fastjson.parser.ParserConfig)13 SimpleDateFormat (java.text.SimpleDateFormat)12 JSONSerializer (com.alibaba.fastjson.serializer.JSONSerializer)10 SimpleDateFormatSerializer (com.alibaba.fastjson.serializer.SimpleDateFormatSerializer)8 SerializeWriter (com.alibaba.fastjson.serializer.SerializeWriter)6 JavaBeanSerializer (com.alibaba.fastjson.serializer.JavaBeanSerializer)4 HashMap (java.util.HashMap)4 DoubleSerializer (com.alibaba.fastjson.serializer.DoubleSerializer)3 SerializerFeature (com.alibaba.fastjson.serializer.SerializerFeature)3 SimplePropertyPreFilter (com.alibaba.fastjson.serializer.SimplePropertyPreFilter)3 AfterFilter (com.alibaba.fastjson.serializer.AfterFilter)2 BeforeFilter (com.alibaba.fastjson.serializer.BeforeFilter)2 NameFilter (com.alibaba.fastjson.serializer.NameFilter)2 PascalNameFilter (com.alibaba.fastjson.serializer.PascalNameFilter)2 PropertyFilter (com.alibaba.fastjson.serializer.PropertyFilter)2 ValueFilter (com.alibaba.fastjson.serializer.ValueFilter)2 BigDecimal (java.math.BigDecimal)2 DecimalFormat (java.text.DecimalFormat)2