本文整理匯總了Java中com.alibaba.fastjson.JSON.writeJSONStringTo方法的典型用法代碼示例。如果您正苦於以下問題:Java JSON.writeJSONStringTo方法的具體用法?Java JSON.writeJSONStringTo怎麽用?Java JSON.writeJSONStringTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.alibaba.fastjson.JSON
的用法示例。
在下文中一共展示了JSON.writeJSONStringTo方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test_0
import com.alibaba.fastjson.JSON; //導入方法依賴的package包/類
public void test_0() throws Exception {
StringWriter out = new StringWriter();
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("a", 123);
JSON.writeJSONStringTo(map, out);
String text = out.toString();
Assert.assertEquals("{\"a\":123}", text);
}
示例2: test_writer
import com.alibaba.fastjson.JSON; //導入方法依賴的package包/類
public void test_writer() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中國");
buf.append("\0");
StringWriter out = new StringWriter();
JSON.writeJSONStringTo(buf.toString(), out, SerializerFeature.BrowserCompatible);
}
示例3: test_singleQuote_writer
import com.alibaba.fastjson.JSON; //導入方法依賴的package包/類
public void test_singleQuote_writer() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中國");
buf.append("\0");
StringWriter out = new StringWriter();
JSON.writeJSONStringTo(Collections.singletonMap(buf.toString(), ""), out, SerializerFeature.UseSingleQuotes);
}
示例4: test_1
import com.alibaba.fastjson.JSON; //導入方法依賴的package包/類
public void test_1() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中國");
buf.append("\0");
StringWriter out = new StringWriter();
JSON.writeJSONStringTo(buf.toString(), out, SerializerFeature.BrowserSecure);
}