code: public String toJson(Map<?, ?> map) {
      StringWriter stringWriter = new StringWriter();
      try {
        toJson(map, stringWriter);
      } catch (IOException e) {
        throw new AssertionError(e); // No I/O writing to a Buffer.
      }
      return stringWriter.toString();
    }
docs: Serializes the map into it's json representation and returns it as a String. If you want to
  write the json to {@link Writer} instead of retrieving it as a String, use {@link #toJson(Map,
  Writer)} instead.