當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。