本文整理了Java中leap.lang.json.JSON.createWriter()
方法的一些代码示例,展示了JSON.createWriter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSON.createWriter()
方法的具体详情如下:
包路径:leap.lang.json.JSON
类名称:JSON
方法名:createWriter
[英]Creates a JsonWriter use StringBuilder as output.
[中]使用StringBuilder作为输出创建JsonWriter。
代码示例来源:origin: org.leapframework/leap-lang
/**
* Creates a {@link JsonWriter} use {@link StringBuilder} as output.
*/
public static JsonWriter createWriter() {
return createWriter(new StringBuilder());
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Encodes the value to json string.
*/
public static String encode(Object value){
return createWriter().value(value).toString();
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Encodes the value to json string with the given settings.
*
* <p/>
* Same as {@link #encode(Object, JsonSettings)}.
*/
public static String stringify(Object value, JsonSettings settings){
return createWriter(settings).value(value).toString();
}
代码示例来源:origin: org.leapframework/leap-core
public String getPayload(Map<String, Object> claims) {
JsonWriter w = JSON.createWriter();
w.map(claims);
return w.toString();
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Encodes the value to json string with the given settings.
*/
public static void encode(Object value, JsonSettings settings, Appendable out){
createWriter(out, settings).value(value);
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Encodes the value to json string.
*
* <p/>
* Same as {@link #encode(Object)}.
*/
public static String stringify(Object value){
return createWriter().value(value).toString();
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Encodes the value to json string with the given settings.
*/
public static String encode(Object value, JsonSettings settings){
return createWriter(settings).value(value).toString();
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Encodes the value to json string.
*/
public static void encode(Object value, Appendable out){
createWriter(out).value(value);
}
代码示例来源:origin: org.leapframework/leap-core
protected String encodePayload(Map<String, Object> claims) {
JsonWriter w = JSON.createWriter();
w.map(claims);
return JWT.base64UrlEncode(w.toString());
}
代码示例来源:origin: org.leapframework/leap-core
protected String encodeHeader(Map<String, Object> claims) {
if(null == encodedHeader) {
JsonWriter w = JSON.createWriter();
w.startObject();
if (isEncodeTyp()) {
w.property("typ", "JWT");
}
w.property("alg", getJwtAlgorithm());
w.endObject();
encodedHeader = JWT.base64UrlEncode(w.toString());
}
return encodedHeader;
}
代码示例来源:origin: org.leapframework/leap-oauth2-webapp
protected void writeError(Request request, Response response, int status, String code, String desc) {
response.setStatus(status);
response.setContentType(ContentTypes.APPLICATION_JSON_UTF8);
JsonWriter json = JSON.createWriter(response.getWriter());
json.startObject()
.property("error", code)
.propertyOptional("error_description", desc)
.endObject();
}
代码示例来源:origin: org.leapframework/leap-oauth2
protected void writeError(Request request, Response response, int status, String code, String desc) {
response.setStatus(status);
response.setContentType(ContentTypes.APPLICATION_JSON_UTF8);
JsonWriter json = JSON.createWriter(response.getWriter());
json.startObject()
.property("error", code)
.propertyOptional("error_description", desc)
.endObject();
}
代码示例来源:origin: org.leapframework/leap-oauth2
public static void response(Response response, OAuth2Error error) {
response.setStatus(error.getStatus());
response.setContentType(ContentTypes.APPLICATION_JSON_UTF8);
JsonWriter w = JSON.createWriter(response.getWriter());
w.startObject()
.property("error", error.getError())
.propertyOptional("error_description", error.getErrorDescription())
.endObject();
}
代码示例来源:origin: org.leapframework/leap-oauth2-server
public static void response(Response response, OAuth2Error error) {
response.setStatus(error.getStatus());
response.setContentType(ContentTypes.APPLICATION_JSON_UTF8);
JsonWriter w = JSON.createWriter(response.getWriter());
w.startObject()
.property("error", error.getError())
.property("error_code", error.getErrorCode())
.propertyOptional("referral", error.getReferral())
.propertyOptional("error_description", error.getErrorDescription())
.endObject();
}
内容来源于网络,如有侵权,请联系作者删除!