Package com.alibaba.fastjson.serializer

Examples of com.alibaba.fastjson.serializer.DoubleSerializer


        Map values = new HashMap();
        Double v = 9.00;
        values.put("double", v);

        SerializeConfig config = new SerializeConfig();
        config.put(Double.class, new DoubleSerializer(new DecimalFormat("###.00")));
        Assert.assertEquals("{\"double\":9.00}", JSON.toJSONString(values, config));
    }
View Full Code Here


public class DoubleTest_custom extends TestCase {

    public void test_0() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.put(Double.class, new DoubleSerializer(new DecimalFormat("###.##")));
        Assert.assertEquals("1.12", JSON.toJSONString(1.123456789D, config));
    }
View Full Code Here

        Assert.assertEquals("1.12", JSON.toJSONString(1.123456789D, config));
    }
   
    public void test_1() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.put(Double.class, new DoubleSerializer("###.###"));
        Assert.assertEquals("1.123", JSON.toJSONString(1.123456789D, config));
    }
View Full Code Here

TOP

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

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.