@Override
  @InterfaceAudience.LimitedPrivate({"Hive"})
  @InterfaceStability.Evolving
  public List<String> serializePartitionSpec(HCatPartitionSpec hcatPartitionSpec) throws HCatException {
    try {
      List<String> stringReps = new ArrayList<String>();
      TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
      for (PartitionSpec partitionSpec : hcatPartitionSpec.partitionSpecProxy.toPartitionSpec()) {
        stringReps.add(serializer.toString(partitionSpec));
      }
      return stringReps;
    }
    catch (TException serializationException) {
      throw new HCatException("Failed to serialize!", serializationException);
    }
  }
MetadataSerializer implementation, that serializes HCat API elements into JSON.
hcatalog/webhcat/java-client/src/main/java/org/apache/hive/hcatalog/api/MetadataJSONSerializer.java