@@ -1403,15 +1403,6 @@ def to_dict(
1403
1403
Dict[:class:`str`, Any]
1404
1404
The JSON serializable dict representation of this object.
1405
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
1406
output : Dict [str , Any ] = {}
1416
1407
field_types = self ._type_hints ()
1417
1408
defaults = self ._betterproto .default_gen
@@ -1530,12 +1521,6 @@ def to_dict(
1530
1521
1531
1522
@classmethod
1532
1523
def _from_dict_init (cls , mapping : Mapping [str , Any ]) -> Mapping [str , Any ]:
1533
- # Special case: google.protobuf.Struct has a single fields member but
1534
- # behaves like a transparent JSON object, so it needs to first be munged
1535
- # into `{fields: mapping}`.
1536
- if cls == Struct :
1537
- mapping = {"fields" : mapping }
1538
-
1539
1524
init_kwargs : Dict [str , Any ] = {}
1540
1525
for key , value in mapping .items ():
1541
1526
field_name = safe_snake_case (key )
@@ -1566,7 +1551,7 @@ def _from_dict_init(cls, mapping: Mapping[str, Any]) -> Mapping[str, Any]:
1566
1551
if isinstance (value , list )
1567
1552
else sub_cls .from_dict (value )
1568
1553
)
1569
- elif meta .map_types and meta .map_types [1 ] == TYPE_MESSAGE and cls != Struct :
1554
+ elif meta .map_types and meta .map_types [1 ] == TYPE_MESSAGE :
1570
1555
sub_cls = cls ._betterproto .cls_by_field [f"{ field_name } .value" ]
1571
1556
value = {k : sub_cls .from_dict (v ) for k , v in value .items ()}
1572
1557
else :
@@ -1941,7 +1926,6 @@ def which_one_of(message: Message, group_name: str) -> Tuple[str, Optional[Any]]
1941
1926
Int32Value ,
1942
1927
Int64Value ,
1943
1928
StringValue ,
1944
- Struct ,
1945
1929
Timestamp ,
1946
1930
UInt32Value ,
1947
1931
UInt64Value ,
0 commit comments