diff --git a/ortools/util/file_util.cc b/ortools/util/file_util.cc index 6ee86f6e52..62d0aaa314 100644 --- a/ortools/util/file_util.cc +++ b/ortools/util/file_util.cc @@ -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)