Package com.alibaba.json.bvt

Source Code of com.alibaba.json.bvt.FeaturesTest5$Entity

package com.alibaba.json.bvt;

import junit.framework.Assert;
import junit.framework.TestCase;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class FeaturesTest5 extends TestCase {

    public void test_0() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.setAsmEnable(false);
       
        String text = JSON.toJSONString(new Entity(), config);
        Assert.assertEquals("{\"value\":false}", text);
    }
   
    public void test_1() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.setAsmEnable(true);
       
        String text = JSON.toJSONString(new Entity(), config);
        Assert.assertEquals("{\"value\":false}", text);
    }

    public static class Entity {

        private Boolean value;

        @JSONField(serialzeFeatures = { SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullBooleanAsFalse })
        public Boolean getValue() {
            return value;
        }


    }
}
TOP

Related Classes of com.alibaba.json.bvt.FeaturesTest5$Entity

TOP
Copyright © 2018 www.massapi.com. 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.