class FeatureSetJsonByteConverter implements OptionByteConverter<List<FeatureSetProto.FeatureSet>> {

  @Override
  public byte[] toByte(List<FeatureSetProto.FeatureSet> featureSets)
      throws InvalidProtocolBufferException {
    JsonFormat.Printer printer =
        JsonFormat.printer().omittingInsignificantWhitespace().printingEnumsAsInts();
    List<String> featureSetsJson = new ArrayList<>();
    for (FeatureSetProto.FeatureSet featureSet : featureSets) {
      featureSetsJson.add(printer.print(featureSet.getSpec()));
    }
    return String.join("\n", featureSetsJson).getBytes();
  }

}