Skip to content

Commit f2e8afc

Browse files
Merge pull request #16 from cetanu/patch-1
Exclude empty lists from to_dict output
2 parents c78851b + dbd438e commit f2e8afc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

betterproto/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,8 @@ def to_dict(self, casing: Casing = Casing.CAMEL, include_default_values: bool =
733733
elif isinstance(v, list):
734734
# Convert each item.
735735
v = [i.to_dict(casing, include_default_values) for i in v]
736-
output[cased_name] = v
736+
if v or include_default_values:
737+
output[cased_name] = v
737738
else:
738739
if v._serialized_on_wire or include_default_values:
739740
output[cased_name] = v.to_dict(casing, include_default_values)

0 commit comments

Comments
 (0)