Java 类com.alibaba.fastjson.serializer.BigDecimalCodec 实例源码

项目:GitHub    文件:BigDecimalDeserializerTest.java   
public void test_bigdecimal() throws Exception {
    Assert.assertEquals(BigDecimal.ZERO, JSON.parseObject("0", BigDecimal.class));
    Assert.assertEquals(BigDecimal.ZERO, JSON.parseObject("'0'", BigDecimal.class));
    Assert.assertEquals(new BigDecimal("0.0"), JSON.parseObject("0.0", BigDecimal.class));
    Assert.assertEquals(new BigDecimal("0.0"), JSON.parseObject("'0.0'", BigDecimal.class));

    Assert.assertEquals(null, JSON.parseObject("null", BigDecimal.class));

    DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
    Assert.assertEquals(null, BigDecimalCodec.instance.deserialze(parser, null, null));
}