本文整理了Java中com.alibaba.fastjson.JSON.writeJSONString()
方法的一些代码示例,展示了JSON.writeJSONString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSON.writeJSONString()
方法的具体详情如下:
包路径:com.alibaba.fastjson.JSON
类名称:JSON
方法名:writeJSONString
暂无
代码示例来源:origin: com.alibaba/fastjson
/**
* @deprecated use writeJSONString
*/
public static void writeJSONStringTo(Object object, Writer writer, SerializerFeature... features) {
writeJSONString(writer, object, features);
}
代码示例来源:origin: com.alibaba/fastjson
/**
* This method serializes the specified object into its equivalent json representation.
*
* @param writer Writer to which the json representation needs to be written
* @param object the object for which json representation is to be created setting for fastjson
* @param features serializer features
* @since 1.2.11
*/
public static void writeJSONString(Writer writer, Object object, SerializerFeature... features) {
writeJSONString(writer, object, JSON.DEFAULT_GENERATE_FEATURE, features);
}
代码示例来源:origin: com.alibaba/fastjson
/**
* write object as json to OutputStream
* @param os output stream
* @param object
* @param features serializer features
* @since 1.2.11
* @throws IOException
*/
public static final int writeJSONString(OutputStream os, //
Object object, //
SerializerFeature... features) throws IOException {
return writeJSONString(os, object, DEFAULT_GENERATE_FEATURE, features);
}
代码示例来源:origin: com.alibaba/fastjson
public static final int writeJSONString(OutputStream os, //
Charset charset, //
Object object, //
SerializerFeature... features) throws IOException {
return writeJSONString(os, //
charset, //
object, //
SerializeConfig.globalInstance, //
null, //
null, //
DEFAULT_GENERATE_FEATURE, //
features);
}
代码示例来源:origin: com.alibaba/fastjson
/**
* @since 1.2.11
*/
public static final int writeJSONString(OutputStream os, //
Object object, //
int defaultFeatures, //
SerializerFeature... features) throws IOException {
return writeJSONString(os, //
IOUtils.UTF8, //
object, //
SerializeConfig.globalInstance, //
null, //
null, //
defaultFeatures, //
features);
}
代码示例来源:origin: alibaba/fastjson
@Override
protected void renderMergedOutputModel(Map<String, Object> model, //
HttpServletRequest request, //
HttpServletResponse response) throws Exception {
Object value = filterModel(model);
String jsonpParameterValue = getJsonpParameterValue(request);
if(jsonpParameterValue != null) {
JSONPObject jsonpObject = new JSONPObject(jsonpParameterValue);
jsonpObject.addParameter(value);
value = jsonpObject;
}
ByteArrayOutputStream outnew = new ByteArrayOutputStream();
int len = JSON.writeJSONString(outnew, //
fastJsonConfig.getCharset(), //
value, //
fastJsonConfig.getSerializeConfig(), //
fastJsonConfig.getSerializeFilters(), //
fastJsonConfig.getDateFormat(), //
JSON.DEFAULT_GENERATE_FEATURE, //
fastJsonConfig.getSerializerFeatures());
if (this.updateContentLength) {
// Write content length (determined via byte array).
response.setContentLength(len);
}
// Flush byte array to servlet output stream.
ServletOutputStream out = response.getOutputStream();
outnew.writeTo(out);
outnew.close();
out.flush();
}
代码示例来源:origin: alibaba/fastjson
JSON.writeJSONString(entityStream, //
代码示例来源:origin: com.alibaba/fastjson
@Override
protected void renderMergedOutputModel(Map<String, Object> model, //
HttpServletRequest request, //
HttpServletResponse response) throws Exception {
Object value = filterModel(model);
String jsonpParameterValue = getJsonpParameterValue(request);
if(jsonpParameterValue != null) {
JSONPObject jsonpObject = new JSONPObject(jsonpParameterValue);
jsonpObject.addParameter(value);
value = jsonpObject;
}
ByteArrayOutputStream outnew = new ByteArrayOutputStream();
int len = JSON.writeJSONString(outnew, //
fastJsonConfig.getCharset(), //
value, //
fastJsonConfig.getSerializeConfig(), //
fastJsonConfig.getSerializeFilters(), //
fastJsonConfig.getDateFormat(), //
JSON.DEFAULT_GENERATE_FEATURE, //
fastJsonConfig.getSerializerFeatures());
if (this.updateContentLength) {
// Write content length (determined via byte array).
response.setContentLength(len);
}
// Flush byte array to servlet output stream.
ServletOutputStream out = response.getOutputStream();
outnew.writeTo(out);
outnew.close();
out.flush();
}
代码示例来源:origin: com.alibaba/fastjson
JSON.writeJSONString(entityStream, //
代码示例来源:origin: com.alibaba/fastjson
int len = JSON.writeJSONString(outnew, //
代码示例来源:origin: mrdear/JavaWEB
model.setConfigs(mianVpns);
JSON.writeJSONString(outputStream, model);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
代码示例来源:origin: hsiafan/requests
@Override
public void marshal(Writer writer, Object value) {
JSON.writeJSONString(writer, value);
}
代码示例来源:origin: zycgit/hasor
@Override
public void writerJson(Object renderData, Writer writerTo) throws Throwable {
JSON.writeJSONString(writerTo, renderData);
}
}
代码示例来源:origin: org.xipki/ca-mgmt-client
private void finalizeZip(ZipOutputStream zipOutStream, String filename, Object container)
throws IOException {
ZipEntry certZipEntry = new ZipEntry(filename);
zipOutStream.putNextEntry(certZipEntry);
try {
JSON.writeJSONString(zipOutStream, Charset.forName("UTF-8"), container);
} finally {
zipOutStream.closeEntry();
}
zipOutStream.close();
}
代码示例来源:origin: org.xipki/ca-mgmt-client
private void finalizeZip(ZipOutputStream zipOutStream, OcspCertstore.Certs certs)
throws IOException {
ZipEntry certZipEntry = new ZipEntry("certs.json");
zipOutStream.putNextEntry(certZipEntry);
try {
JSON.writeJSONString(zipOutStream, Charset.forName("UTF-8"), certs);
} finally {
zipOutStream.closeEntry();
}
zipOutStream.close();
}
代码示例来源:origin: cowtowncoder/java-json-performance-benchmarks
@Override
public int _writeItems(MeasurementPOJO items, Writer out) throws Exception
{
JSON.writeJSONString(out, items, SerializerFeature.DisableCircularReferenceDetect);
return items.size();
}
代码示例来源:origin: cowtowncoder/java-json-performance-benchmarks
@Override
public int _writeItems(MeasurementPOJO items, OutputStream out) throws Exception
{
JSON.writeJSONString(out, items, SerializerFeature.DisableCircularReferenceDetect);
return items.size();
}
代码示例来源:origin: org.xipki/ca-api
public static void marshal(CaConfType.CaSystem root, OutputStream out)
throws InvalidConfException, IOException {
Args.notNull(root, "root");
Args.notNull(out, "out");
root.validate();
JSON.writeJSONString(out, Charset.forName("UTF8"), root, SerializerFeature.PrettyFormat);
}
代码示例来源:origin: alipay/sofa-lookout
private static void sendResponse(HttpExchange exchange, Object bodyEntity) throws IOException {
exchange.getResponseHeaders().set("Content-Type", "application/json;charset=utf-8");
exchange.getResponseHeaders().set("Content-Encoding", "gzip");
exchange.sendResponseHeaders(200, 0);
OutputStream os = new GZIPOutputStream(exchange.getResponseBody());
try {
JSON.writeJSONString(os, UTF8, bodyEntity);
} finally {
os.close();
}
}
代码示例来源:origin: fabienrenaud/java-json-benchmark
@Benchmark
@Override
public Object fastjson() throws Exception {
ByteArrayOutputStream baos = JsonUtils.byteArrayOutputStream();
JSON.writeJSONString(baos, JSON_SOURCE().nextPojo(), SerializerFeature.EMPTY);
return baos;
}
内容来源于网络,如有侵权,请联系作者删除!