There is now a built-in method method to recursively convert a Struct
to native python objects: google.protobuf.json_format.MessageToDict()
Here's the documentation for this method: https://googleapis.dev/python/protobuf/latest/google/protobuf/json_format.html
from google.protobuf.json_format import MessageToDict
from google.protobuf.struct_pb2 import Struct
struct = Struct()
struct.update({"hi": 1, "over": [23, 45, None, 6.7, "there", [8.9, "10"], {"key": None}]})
out = MessageToDict(struct)
print(out)
Output:
{'hi': 1.0, 'over': [23.0, 45.0, None, 6.7, 'there', [8.9, '10'], {'key': None}]}