本文整理汇总了Java中com.alibaba.fastjson.serializer.SerializeConfig.setAsmEnable方法的典型用法代码示例。如果您正苦于以下问题:Java SerializeConfig.setAsmEnable方法的具体用法?Java SerializeConfig.setAsmEnable怎么用?Java SerializeConfig.setAsmEnable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.serializer.SerializeConfig
的用法示例。
在下文中一共展示了SerializeConfig.setAsmEnable方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_codec_3_asm
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_codec_3_asm() throws Exception {
V0 v = new V0();
v.setValue(new BigDecimal("3.2"));
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(true);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
Assert.assertEquals("{\"value\":3.2}", text);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(new BigDecimal("3.2"), v1.getValue());
}
示例2: test_codec_null
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_codec_null() throws Exception {
User user = new User();
user.setValue(null);
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(user, mapping, SerializerFeature.WriteMapNullValue);
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
示例3: test_codec_asm
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_codec_asm() throws Exception {
V0 v = new V0();
v.setValue(new Date());
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(true);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", JSON.defaultLocale);
format.setTimeZone(JSON.defaultTimeZone);
Assert.assertEquals("{\"value\":" + JSON.toJSONString(format.format(v.getValue())) + "}", text);
}
示例4: test_1
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_1() throws Exception {
SerializeConfig config = new SerializeConfig();
config.setAsmEnable(true);
String text = JSON.toJSONString(new Entity(), config);
Assert.assertEquals("{\"value\":null}", text);
}
示例5: test_codec
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_codec() throws Exception {
User user = new User();
user.setValue(Charset.forName("UTF-8"));
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(user, mapping, SerializerFeature.WriteMapNullValue);
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
示例6: test_codec_2_no_asm
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_codec_2_no_asm() throws Exception {
V0 v = new V0();
v.setValue(Long.MAX_VALUE);
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
Assert.assertEquals("{\"value\":" + Long.MAX_VALUE + "}", text);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(new Long(Long.MAX_VALUE), v1.getValue());
}
示例7: test_codec_no_asm
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_codec_no_asm() throws Exception {
V0 v = new V0();
v.setValue(new Date());
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", JSON.defaultLocale);
format.setTimeZone(JSON.defaultTimeZone);
Assert.assertEquals("{\"value\":" + JSON.toJSONString(format.format(v.getValue())) + "}", text);
}
示例8: test_codec_asm
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_codec_asm() throws Exception {
V0 v = new V0();
v.setValue(new Date());
SerializeConfig mapping = new SerializeConfig();
mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));
mapping.setAsmEnable(true);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", JSON.defaultLocale);
format.setTimeZone(JSON.defaultTimeZone);
Assert.assertEquals("{\"value\":" + JSON.toJSONString(format.format(v.getValue())) + "}", text);
}
示例9: test_codec_null_1
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_codec_null_1() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Assert.assertEquals("{\"value\":null}", JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
Assert.assertEquals("{value:null}", JSON.toJSONStringZ(v, mapping, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
Assert.assertEquals("{value:null}", JSON.toJSONStringZ(v, mapping, SerializerFeature.UseSingleQuotes, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
Assert.assertEquals("{'value':null}", JSON.toJSONStringZ(v, mapping, SerializerFeature.UseSingleQuotes, SerializerFeature.QuoteFieldNames, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
}
示例10: test_0
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_0() throws Exception {
SerializeConfig config = new SerializeConfig();
config.setAsmEnable(false);
String text = JSON.toJSONString(new Entity(), config);
Assert.assertEquals("{\"value\":\"\"}", text);
}
示例11: test_codec
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_codec() throws Exception {
User user = new User();
user.setValue(URI.create("http://www.alibaba.com/abc"));
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(user, mapping, SerializerFeature.WriteMapNullValue);
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
示例12: test_codec_null
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_codec_null() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
Assert.assertEquals("{\"value\":null}", text);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue(), v.getValue());
}
示例13: test_codec_null_1
import com.alibaba.fastjson.serializer.SerializeConfig; //导入方法依赖的package包/类
public void test_codec_null_1() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullNumberAsZero);
Assert.assertEquals("{\"value\":null}", text);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(null, v1.getValue());
}