static ReadableStreamChannel serializeJsonToChannel(JSONObject jsonObject) throws RestServiceException {
    try {
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      try (Writer writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)) {
        jsonObject.write(writer);
      }
      return new ByteBufferReadableStreamChannel(ByteBuffer.wrap(outputStream.toByteArray()));
    } catch (Exception e) {
      throw new RestServiceException("Could not serialize response json.", e, RestServiceErrorCode.InternalServerError);
    }
  }
@param jsonObject the {@link JSONObject} to serialize.
@return the {@link ReadableStreamChannel} containing UTF-8 formatted json.
@throws RestServiceException if there was an error during serialization.
ambry-frontend/src/main/java/com/github/ambry/frontend/FrontendUtils.java