BooleanDeserializerTest.java 文件源码

java
阅读 92 收藏 0 点赞 0 评论 0

项目:GitHub 作者:
public void test_boolean() throws Exception {
    Assert.assertEquals(Boolean.TRUE, JSON.parseObject("true", Boolean.class));
    Assert.assertEquals(Boolean.FALSE, JSON.parseObject("false", Boolean.class));

    Assert.assertEquals(Boolean.TRUE, JSON.parseObject("'true'", Boolean.class));
    Assert.assertEquals(Boolean.FALSE, JSON.parseObject("'false'", Boolean.class));

    Assert.assertEquals(Boolean.TRUE, JSON.parseObject("1", Boolean.class));
    Assert.assertEquals(Boolean.FALSE, JSON.parseObject("0", Boolean.class));

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

    {
        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(),
                                                         JSON.DEFAULT_PARSER_FEATURE);
        Assert.assertEquals(null, BooleanCodec.instance.deserialze(parser, null, null));
        parser.close();
    }
    Assert.assertEquals(JSONToken.TRUE, BooleanCodec.instance.getFastMatchToken());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号