userver: en/testsuite/protobuf/utils.py Source File
Loading...
Searching...
No Matches
utils.py
1import google.protobuf.json_format
2import google.protobuf.message
3
4
5def message_to_dict(msg) -> dict:
6 """Convert a protobuf message to a plain dict, preserving field names."""
7 return google.protobuf.json_format.MessageToDict(
8 msg,
9 preserving_proto_field_name=True,
10 )