We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cd39656 commit f5a3eeeCopy full SHA for f5a3eee
src/betterproto/__init__.py
@@ -1403,6 +1403,15 @@ def to_dict(
1403
Dict[:class:`str`, Any]
1404
The JSON serializable dict representation of this object.
1405
"""
1406
+ # Mirror of from_dict: Struct's `fields` member is transparently
1407
+ # dispatched through instead.
1408
+ if isinstance(self, Struct):
1409
+ output = {**self.fields}
1410
+ for k in self.fields:
1411
+ if hasattr(self.fields[k], "to_dict"):
1412
+ output[k] = self.fields[k].to_dict(casing, include_default_values)
1413
+ return output
1414
+
1415
output: Dict[str, Any] = {}
1416
field_types = self._type_hints()
1417
defaults = self._betterproto.default_gen
0 commit comments