private static Charset requestedCharset(MediaType mediaType) {
    return Optional.ofNullable(mediaType).map(MediaType::getParameters)
      .map(params -> params.get("charset")).map(c -> {
        try {
          return Charset.forName(c);
        } catch (IllegalCharsetNameException e) {
          logger.debug("Client requested illegal Charset '{}'", c);
          return null;
        } catch (UnsupportedCharsetException e) {
          logger.debug("Client requested unsupported Charset '{}'", c);
          return null;
        } catch (Exception e) {
          logger.debug("Error while resolving Charset '{}'", c, e);
          return null;
        }
      }).orElse(StandardCharsets.UTF_8);
  }
Implements JSON serialization via {@link Gson} for JAX-RS.
hbase-http/src/main/java/org/apache/hadoop/hbase/http/gson/GsonMessageBodyWriter.java