本文整理汇总了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);
}