当前位置: 首页>>代码示例>>Java>>正文


Java SerializerFeature.UseSingleQuotes方法代码示例

本文整理汇总了Java中com.alibaba.fastjson.serializer.SerializerFeature.UseSingleQuotes方法的典型用法代码示例。如果您正苦于以下问题:Java SerializerFeature.UseSingleQuotes方法的具体用法?Java SerializerFeature.UseSingleQuotes怎么用?Java SerializerFeature.UseSingleQuotes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.fastjson.serializer.SerializerFeature的用法示例。


在下文中一共展示了SerializerFeature.UseSingleQuotes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_enum

import com.alibaba.fastjson.serializer.SerializerFeature; //导入方法依赖的package包/类
public void test_enum() throws Exception {
    Date date = new Date(1308841916550L);
    Assert.assertEquals("1308841916550", JSON.toJSONString(date)); // 1308841916550
    System.out.println(JSON.toJSONString(date, SerializerFeature.UseISO8601DateFormat)); // "2011-06-23T23:11:56.550"
    SerializerFeature[] features = {SerializerFeature.UseISO8601DateFormat, SerializerFeature.UseSingleQuotes };
    System.out.println(JSON.toJSONString(date, features)); // '2011-06-23T23:11:56.550'
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:EnumTest2.java

示例2: test_enum_noasm

import com.alibaba.fastjson.serializer.SerializerFeature; //导入方法依赖的package包/类
public void test_enum_noasm() throws Exception {
    SerializeConfig mapping = new SerializeConfig();
    mapping.setAsmEnable(false);
    
    Date date = new Date(1308841916550L);
    Assert.assertEquals("1308841916550", JSON.toJSONString(date, mapping)); // 1308841916550
    Assert.assertEquals("\"2011-06-23T23:11:56.550+08:00\"", JSON.toJSONString(date, mapping, SerializerFeature.UseISO8601DateFormat)); // "2011-06-23T23:11:56.550"
    SerializerFeature[] features = {SerializerFeature.UseISO8601DateFormat, SerializerFeature.UseSingleQuotes };
    Assert.assertEquals("'2011-06-23T23:11:56.550+08:00'", JSON.toJSONString(date, mapping, features)); // '2011-06-23T23:11:56.550'
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:EnumTest2.java

示例3: test_1

import com.alibaba.fastjson.serializer.SerializerFeature; //导入方法依赖的package包/类
public void test_1 () throws Exception {
    SerializeWriter out = new SerializeWriter(SerializerFeature.UseSingleQuotes);
    out.writeString("abc中文");
    
    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    out.writeTo(byteOut, "UTF-8");
    Assert.assertEquals("'abc中文'", new String(byteOut.toByteArray(), "UTF-8"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:SerializeWriterTest_1.java

示例4: test_0

import com.alibaba.fastjson.serializer.SerializerFeature; //导入方法依赖的package包/类
public void test_0 () throws Exception {
    SerializeWriter out = new SerializeWriter(SerializerFeature.UseSingleQuotes);
    out.writeString("abc");
    Assert.assertEquals("'abc'", out.toString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:SerializeWriterTest_1.java

示例5: test_2

import com.alibaba.fastjson.serializer.SerializerFeature; //导入方法依赖的package包/类
public void test_2 () throws Exception {
    SerializeWriter out = new SerializeWriter(SerializerFeature.UseSingleQuotes);
    out.writeString("abc");
    Assert.assertEquals("'abc'", new String(out.toBytes((String) null), "ISO-8859-1"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:SerializeWriterTest_1.java

示例6: test_3

import com.alibaba.fastjson.serializer.SerializerFeature; //导入方法依赖的package包/类
public void test_3 () throws Exception {
    SerializeWriter out = new SerializeWriter(SerializerFeature.UseSingleQuotes);
    out.writeString("abc");
    Assert.assertEquals("'abc'", new String(out.toBytes("UTF-16"), "UTF-16"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:SerializeWriterTest_1.java


注:本文中的com.alibaba.fastjson.serializer.SerializerFeature.UseSingleQuotes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。