Package com.alibaba.fastjson.serializer

Examples of com.alibaba.fastjson.serializer.SerializeConfig


public class BooleanArrayFieldTest extends TestCase {

    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);
View Full Code Here


import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;

public class DateFieldTest6 extends TestCase {
  public void test_0() throws Exception {
    SerializeConfig mapping = new SerializeConfig();
    mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));

    Entity object = new Entity();
    object.setValue(new Date());
    String text = JSON.toJSONString(object, mapping);
    Assert.assertEquals("{\"value\":\"" + new SimpleDateFormat("yyyy-MM-dd").format(object.getValue()) + "\"}", text);
View Full Code Here

    public void test_codec() throws Exception {
        User user = new User();
        user.setValue(1001D);

        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);
View Full Code Here

    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);
        System.out.println(text);

        User user1 = JSON.parseObject(text, User.class);
View Full Code Here

public class AppendableFieldTest extends TestCase {

    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);
    }
View Full Code Here

    }

    public void test_codec_null_1() throws Exception {
        V0 v = new V0();

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);
        Assert.assertTrue(!mapping.isAsmEnable());

        String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
        Assert.assertEquals("{\"value\":\"\"}", text);
    }
View Full Code Here

public class ObjectFieldTest extends TestCase {

    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);
View Full Code Here

        }
    }

    public void test_codec_null_1() throws Exception {

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);
        {
            V0 v = new V0();

            String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty);
            Assert.assertEquals("{\"value\":null}", text);
View Full Code Here

import com.alibaba.fastjson.serializer.SerializeConfig;

public class SerializeConfigTest extends TestCase {

    public void test_0() throws Exception {
        SerializeConfig config = new SerializeConfig();

        Exception error = null;
        try {
            config.createJavaBeanSerializer(int.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

        sdh5724.getGroups().add(admin);
       
        sager.setReportTo(sdh5724);
        jobs.setReportTo(sdh5724);

        SerializeConfig serializeConfig = new SerializeConfig();
        serializeConfig.setAsmEnable(false);
        String text = JSON.toJSONString(admin, serializeConfig, SerializerFeature.PrettyFormat);
        System.out.println(text);
       
        ParserConfig config = new ParserConfig();
        config.setAsmEnable(false);
View Full Code Here

TOP

Related Classes of com.alibaba.fastjson.serializer.SerializeConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.