本文整理了Java中org.rapidoid.data.JSON.stringify()
方法的一些代码示例,展示了JSON.stringify()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSON.stringify()
方法的具体详情如下:
包路径:org.rapidoid.data.JSON
类名称:JSON
方法名:stringify
暂无
代码示例来源:origin: rapidoid/rapidoid
@Override
public Channel writeJSON(Object value) {
JSON.stringify(value, output.asOutputStream());
return this;
}
代码示例来源:origin: rapidoid/rapidoid
public static Map<String, Object> deepCopyOf(Map<String, Object> map) {
return JSON.parseMap(JSON.stringify(map)); // FIXME proper implementation
}
代码示例来源:origin: rapidoid/rapidoid
public static void warmUp() {
Msc.thread(() -> {
JSON.stringify(123);
JSON.parse("{}", Map.class);
});
}
代码示例来源:origin: rapidoid/rapidoid
private static NByteArrayEntity paramsBody(Map<String, Object> data, Map<String, List<Upload>> files) {
data = U.safe(data);
files = U.safe(files);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
for (Map.Entry<String, List<Upload>> entry : files.entrySet()) {
for (Upload file : entry.getValue()) {
builder = builder.addBinaryBody(entry.getKey(), file.content(), ContentType.DEFAULT_BINARY, file.filename());
}
}
for (Map.Entry<String, Object> entry : data.entrySet()) {
String name = entry.getKey();
String value = JSON.stringify(entry.getValue());
builder = builder.addTextBody(name, value, ContentType.APPLICATION_JSON);
}
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
builder.build().writeTo(stream);
} catch (IOException e) {
throw U.rte(e);
}
byte[] bytes = stream.toByteArray();
return new NByteArrayEntity(bytes, ContentType.MULTIPART_FORM_DATA);
}
代码示例来源:origin: rapidoid/rapidoid
private void writeJsonBody(MaybeReq req, Buf out, Object value) {
// Content-Length header
out.append(CONTENT_LENGTH_UNKNOWN);
int posConLen = out.size() - 1;
out.append(CR_LF);
closeHeaders(req, out);
int posBefore = out.size();
JSON.stringify(value, out.asOutputStream());
int posAfter = out.size();
int contentLength = posAfter - posBefore;
out.putNumAsText(posConLen, contentLength, false);
}
代码示例来源:origin: rapidoid/rapidoid
private void writeJsonResponse(MaybeReq req, Resp resp, Channel ctx, boolean isKeepAlive,
int code, MediaType contentType, Object result) {
startResponse(resp, ctx, code, isKeepAlive, contentType);
RapidoidThreadLocals locals = Msc.locals();
ReusableWritable out = locals.jsonRenderingStream();
// FIXME headers
JSON.stringify(result, out);
writeContentLengthHeader(ctx, out.size());
closeHeaders(req, ctx.output());
ctx.write(out.array(), 0, out.size());
}
代码示例来源:origin: rapidoid/rapidoid
protected void writeJsonBody(MaybeReq req, Channel ctx, Object value) {
writeContentTypeHeader(ctx, MediaType.JSON);
ReusableWritable out = Msc.locals().jsonRenderingStream();
JSON.stringify(value, out);
HttpIO.INSTANCE.writeContentLengthHeader(ctx, out.size());
HttpIO.INSTANCE.closeHeaders(req, ctx.output());
ctx.write(out.array(), 0, out.size());
}
代码示例来源:origin: rapidoid/rapidoid
str = "'" + Str.sub(JSON.stringify(arg), 1, -1) + "'";
} else {
str = U.str(arg);
代码示例来源:origin: org.rapidoid/rapidoid-jackson
public static void warmup() {
JSON.stringify(123);
JSON.parse("{}", Map.class);
}
代码示例来源:origin: org.rapidoid/rapidoid-beany
public static void toJSON(Object value, OutputStream out) {
JSON.stringify(Beany.serialize(value), out);
}
代码示例来源:origin: org.rapidoid/rapidoid-beany
public static String toJSON(Object value) {
return JSON.stringify(serialize(value));
}
代码示例来源:origin: org.rapidoid/rapidoid-beany
public static String save(Object value) {
Object ser = Beany.serialize(value);
Class<?> cls = value != null ? value.getClass() : null;
Map<String, Object> map = U.map("_", cls.getCanonicalName(), "v", ser);
return JSON.stringify(map);
}
代码示例来源:origin: org.rapidoid/rapidoid-http
public synchronized String renderState() {
try {
return JSON.stringify(serializeLocals());
} catch (Exception e) {
Log.error("Cannot render state tag!", e);
return "{}";
}
}
代码示例来源:origin: org.rapidoid/rapidoid-http
private void beforeClosingHeaders() {
byte[] cpack = serializeCookiepack();
if (cpack != null) {
String json = U.mid(JSON.stringify(cpack), 1, -1);
setCookie(COOKIEPACK_COOKIE, json, "path=/");
}
}
代码示例来源:origin: org.rapidoid/rapidoid-http-fast
private void writeJsonBody(MaybeReq req, Buf out, Object value) {
// Content-Length header
out.append(CONTENT_LENGTH_UNKNOWN);
int posConLen = out.size() - 1;
out.append(CR_LF);
closeHeaders(req, out);
int posBefore = out.size();
JSON.stringify(value, out.asOutputStream());
int posAfter = out.size();
int contentLength = posAfter - posBefore;
out.putNumAsText(posConLen, contentLength, false);
}
代码示例来源:origin: org.rapidoid/rapidoid-http-fast
private void writeJsonResponse(MaybeReq req, Resp resp, Channel ctx, boolean isKeepAlive,
int code, MediaType contentType, Object result) {
startResponse(resp, ctx, code, isKeepAlive, contentType);
RapidoidThreadLocals locals = Msc.locals();
ReusableWritable out = locals.jsonRenderingStream();
// FIXME headers
JSON.stringify(result, out);
writeContentLengthHeader(ctx, out.size());
closeHeaders(req, ctx.output());
ctx.write(out.array(), 0, out.size());
}
代码示例来源:origin: org.rapidoid/rapidoid-http-fast
protected void writeJsonBody(MaybeReq req, Channel ctx, Object value) {
writeContentTypeHeader(ctx, MediaType.JSON);
ReusableWritable out = Msc.locals().jsonRenderingStream();
JSON.stringify(value, out);
HttpIO.INSTANCE.writeContentLengthHeader(ctx, out.size());
HttpIO.INSTANCE.closeHeaders(req, ctx.output());
ctx.write(out.array(), 0, out.size());
}
内容来源于网络,如有侵权,请联系作者删除!