@Override
  public void writeTo(T t, Class<?> type, Type genericType, Annotation[] annotations,
    MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
    throws IOException, WebApplicationException {
    final Charset outputCharset = requestedCharset(mediaType);
    try (Writer writer = new OutputStreamWriter(entityStream, outputCharset)) {
      gson.toJson(t, writer);
    }
  }
Implements JSON serialization via {@link Gson} for JAX-RS.
hbase-http/src/main/java/org/apache/hadoop/hbase/http/gson/GsonMessageBodyWriter.java