本文整理匯總了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"));
}