use of net.morimekta.util.json.JsonWriter in project providence by morimekta.
the class JsonSerializer method serialize.
@Override
public <T extends PMessage<T, F>, F extends PField> int serialize(@Nonnull OutputStream output, @Nonnull T message) throws IOException {
CountingOutputStream counter = new CountingOutputStream(output);
JsonWriter jsonWriter = prettyPrint ? new PrettyJsonWriter(counter) : new JsonWriter(counter);
appendMessage(jsonWriter, message);
jsonWriter.flush();
counter.flush();
return counter.getByteCount();
}
use of net.morimekta.util.json.JsonWriter in project providence by morimekta.
the class JsonSerializer method serialize.
@Override
public <T extends PMessage<T, F>, F extends PField> int serialize(@Nonnull OutputStream output, @Nonnull PServiceCall<T, F> call) throws IOException {
CountingOutputStream counter = new CountingOutputStream(output);
JsonWriter jsonWriter = prettyPrint ? new PrettyJsonWriter(counter) : new JsonWriter(counter);
jsonWriter.array().value(call.getMethod());
if (enumValueType == IdType.ID) {
jsonWriter.value(call.getType().asInteger());
} else {
jsonWriter.valueUnescaped(call.getType().asString().toLowerCase(Locale.US));
}
jsonWriter.value(call.getSequence());
appendMessage(jsonWriter, call.getMessage());
jsonWriter.endArray().flush();
counter.flush();
return counter.getByteCount();
}
use of net.morimekta.util.json.JsonWriter in project providence by morimekta.
the class JsonSerializer method serialize.
public <T extends PMessage<T, F>, F extends PField> void serialize(@Nonnull PrintWriter output, @Nonnull T message) throws IOException {
JsonWriter jsonWriter = prettyPrint ? new PrettyJsonWriter(new IndentedPrintWriter(output)) : new JsonWriter(output);
appendMessage(jsonWriter, message);
jsonWriter.flush();
}
Aggregations