Search in sources :

Example 1 with JsonOutputWriter

use of com.thoughtworks.go.api.base.JsonOutputWriter in project gocd by gocd.

the class ControllerMethods method jsonizeAsTopLevelObject.

default String jsonizeAsTopLevelObject(Request request, Consumer<OutputWriter> consumer) {
    StringWriter writer = new StringWriter(1024);
    new JsonOutputWriter(writer, RequestContext.requestContext(request)).forTopLevelObject(consumer);
    return writer.toString();
}
Also used : StringWriter(java.io.StringWriter) JsonOutputWriter(com.thoughtworks.go.api.base.JsonOutputWriter)

Example 2 with JsonOutputWriter

use of com.thoughtworks.go.api.base.JsonOutputWriter in project gocd by gocd.

the class MessageJson method toString.

public String toString() {
    StringWriter buffer = new StringWriter(1024);
    new JsonOutputWriter(buffer, null).forTopLevelObject((OutputWriter writer) -> {
        writer.add("message", message);
        if (data != null) {
            writer.add("data", data);
        }
    });
    return buffer.toString();
}
Also used : StringWriter(java.io.StringWriter) JsonOutputWriter(com.thoughtworks.go.api.base.JsonOutputWriter) OutputWriter(com.thoughtworks.go.api.base.OutputWriter) JsonOutputWriter(com.thoughtworks.go.api.base.JsonOutputWriter)

Example 3 with JsonOutputWriter

use of com.thoughtworks.go.api.base.JsonOutputWriter in project gocd by gocd.

the class ControllerMethods method jsonizeAsTopLevelArray.

default String jsonizeAsTopLevelArray(Request request, Consumer<OutputListWriter> consumer) {
    StringWriter writer = new StringWriter(1024);
    new JsonOutputWriter(writer, RequestContext.requestContext(request)).forTopLevelArray(consumer);
    return writer.toString();
}
Also used : StringWriter(java.io.StringWriter) JsonOutputWriter(com.thoughtworks.go.api.base.JsonOutputWriter)

Aggregations

JsonOutputWriter (com.thoughtworks.go.api.base.JsonOutputWriter)3 StringWriter (java.io.StringWriter)3 OutputWriter (com.thoughtworks.go.api.base.OutputWriter)1