public void exportInJson(List<MetadataTableSummary> tableSummaryList, String filename) throws IOException {
    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    JsonElement element = gson.toJsonTree(tableSummaryList);
    // flatten the extra summary
    if (element.isJsonArray()) {
      JsonArray elements = element.getAsJsonArray();
      for (JsonElement outer : elements) {
        if (!outer.isJsonObject()) {
          continue;
        }
        JsonObject object = outer.getAsJsonObject();
        JsonElement innerElement = object.get("summary");
        if (innerElement != null && innerElement.isJsonObject()) {
          JsonObject innerObject = innerElement.getAsJsonObject();
          for (String fieldName : innerObject.keySet().toArray(new String[0])) {
            object.add(fieldName, innerObject.remove(fieldName));
          }
          object.remove("summary");
        }
      }
    }
    writeJsonInFile(gson.toJson(element), filename);
  }
Exporting the MetadataSummary in JSON format.

@param tableSummaryList
@param filename         fully qualified path of the output file
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/metatool/MetaToolTaskMetadataSummary.java