Search in sources :

Example 1 with Entity

use of com.alibaba.json.bvt.serializer.BooleanFieldSerializerTest.Entity in project fastjson by alibaba.

the class BooleanFieldSerializerTest_primitive method test_codec_no_asm.

public void test_codec_no_asm() throws Exception {
    Entity v = new Entity();
    SerializeConfig mapping = new SerializeConfig();
    mapping.setAsmEnable(false);
    String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
    Assert.assertEquals("{\"value\":false}", text);
    Entity v1 = JSON.parseObject(text, Entity.class);
    Assert.assertEquals(v.getValue(), v1.getValue());
}
Also used : Entity(com.alibaba.json.bvt.serializer.BooleanFieldSerializerTest.Entity) SerializeConfig(com.alibaba.fastjson.serializer.SerializeConfig)

Example 2 with Entity

use of com.alibaba.json.bvt.serializer.BooleanFieldSerializerTest.Entity in project fastjson by alibaba.

the class BooleanFieldSerializerTest_primitive method test_codec_2.

public void test_codec_2() throws Exception {
    Entity v1 = parseObjectNoAsm("{value:null}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);
    Assert.assertEquals(false, v1.getValue());
}
Also used : Entity(com.alibaba.json.bvt.serializer.BooleanFieldSerializerTest.Entity)

Example 3 with Entity

use of com.alibaba.json.bvt.serializer.BooleanFieldSerializerTest.Entity in project fastjson by alibaba.

the class BooleanFieldSerializerTest_primitive method test_codec_1.

public void test_codec_1() throws Exception {
    Entity v1 = parseObjectNoAsm("{value:'true'}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);
    Assert.assertEquals(true, v1.getValue());
}
Also used : Entity(com.alibaba.json.bvt.serializer.BooleanFieldSerializerTest.Entity)

Example 4 with Entity

use of com.alibaba.json.bvt.serializer.BooleanFieldSerializerTest.Entity in project fastjson by alibaba.

the class BooleanFieldSerializerTest_primitive method test_codec_0.

public void test_codec_0() throws Exception {
    Entity v1 = parseObjectNoAsm("{value:0}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);
    Assert.assertEquals(false, v1.getValue());
}
Also used : Entity(com.alibaba.json.bvt.serializer.BooleanFieldSerializerTest.Entity)

Example 5 with Entity

use of com.alibaba.json.bvt.serializer.BooleanFieldSerializerTest.Entity in project fastjson by alibaba.

the class BooleanFieldSerializerTest_primitive method test_codec_3.

public void test_codec_3() throws Exception {
    Entity v1 = parseObjectNoAsm("{value:\"\"}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);
    Assert.assertEquals(false, v1.getValue());
}
Also used : Entity(com.alibaba.json.bvt.serializer.BooleanFieldSerializerTest.Entity)

Aggregations

Entity (com.alibaba.json.bvt.serializer.BooleanFieldSerializerTest.Entity)6 SerializeConfig (com.alibaba.fastjson.serializer.SerializeConfig)1