本文整理汇总了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'
}
示例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'
}
示例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"));
}
示例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());
}
示例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"));
}
示例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"));
}