code: public void toJson(Map<?, ?> map, Writer writer) throws IOException {
      if (map == null) {
        throw new IllegalArgumentException("map == null");
      }
      if (writer == null) {
        throw new IllegalArgumentException("writer == null");
      }
  
      JsonWriter jsonWriter = new JsonWriter(writer);
      jsonWriter.setLenient(isLenient);
      if (prettyPrint) {
        jsonWriter.setIndent("  ");
      }
      try {
        mapToWriter(map, jsonWriter);
      } finally {
        jsonWriter.close();
      }
    }
docs: Serializes the map into it's json representation into the provided {@link Writer}. If you want
  to retrieve the json as a string, use {@link #toJson(Map)} instead.