Merge pull request #4697 from clementperon/fix_compat_protobuf

Fix compat with protobuf < 5.26
This commit is contained in:
Laurent Perron
2025-06-18 21:33:15 +02:00
committed by GitHub

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)