code: public static void serialise(OutputStream output, Object responseMessage)
              throws IOException {
  
          Gson gson = getBuilder().create();
          try (OutputStreamWriter writer = new OutputStreamWriter(output, StandardCharsets.UTF_8)) {
              gson.toJson(responseMessage, writer);
          }
      }
docs: Serialises the given object to Json and writes it to the given
  {@link OutputStream}.
  
  @param output          The output stream to serialise to.
  @param responseMessage The message to be serialised.
  @throws IOException If an error occurs in writing the output.