use of com.alibaba.fastjson.serializer.DoubleSerializer in project fastjson by alibaba.
the class DoubleTest_custom method test_1.
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));
}
use of com.alibaba.fastjson.serializer.DoubleSerializer in project fastjson by alibaba.
the class DoubleTest_custom2 method test_0.
@SuppressWarnings({ "rawtypes", "unchecked" })
public void test_0() throws Exception {
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));
}
use of com.alibaba.fastjson.serializer.DoubleSerializer in project fastjson by alibaba.
the class DoubleTest_custom method test_0.
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));
}
Aggregations