ortools: utils: keep compatibility with protobuf < 26

This commit is contained in:
Clément Péron
2025-06-18 18:05:38 +02:00
committed by Corentin Le Molgat
parent 9fa309b358
commit 78b662a2b2

View File

@@ -166,7 +166,11 @@ absl::Status WriteProtoToFile(absl::string_view filename,
case ProtoWriteFormat::kJson: {
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
#if PROTOBUF_VERSION >= 5026000 // Version 26.0.0
options.always_print_fields_with_no_presence = true;
#else
options.always_print_primitive_fields = true;
#endif
options.preserve_proto_field_names = true;
if (!google::protobuf::util::MessageToJsonString(proto, &output_string,
options)