Skip to content

Commit

Permalink
Fix (de)serialization issues with unicode keys in dict and object type
Browse files Browse the repository at this point in the history
  • Loading branch information
lmazuel committed Feb 10, 2017
1 parent a1ae365 commit a98d9e1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions msrest/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ def serialize_dict(self, attr, dict_type, **kwargs):
serialized = {}
for key, value in attr.items():
try:
serialized[str(key)] = self.serialize_data(
serialized[self.serialize_unicode(key)] = self.serialize_data(
value, dict_type, **kwargs)
except ValueError:
serialized[str(key)] = None
serialized[self.serialize_unicode(key)] = None
return serialized

def serialize_object(self, attr, **kwargs):
Expand All @@ -523,10 +523,10 @@ def serialize_object(self, attr, **kwargs):
serialized = {}
for key, value in attr.items():
try:
serialized[str(key)] = self.serialize_object(
serialized[self.serialize_unicode(key)] = self.serialize_object(
value, **kwargs)
except ValueError:
serialized[str(key)] = None
serialized[self.serialize_unicode(key)] = None
return serialized

if obj_type == list:
Expand Down Expand Up @@ -898,9 +898,9 @@ def deserialize_dict(self, attr, dict_type):
:rtype: dict
"""
if isinstance(attr, list):
return {str(x['key']): self.deserialize_data(
return {x['key']: self.deserialize_data(
x['value'], dict_type) for x in attr}
return {str(k): self.deserialize_data(
return {k: self.deserialize_data(
v, dict_type) for k, v in attr.items()}

def deserialize_object(self, attr, **kwargs):
Expand All @@ -923,10 +923,10 @@ def deserialize_object(self, attr, **kwargs):
deserialized = {}
for key, value in attr.items():
try:
deserialized[str(key)] = self.deserialize_object(
deserialized[key] = self.deserialize_object(
value, **kwargs)
except ValueError:
deserialized[str(key)] = None
deserialized[key] = None
return deserialized

if obj_type == list:
Expand Down

0 comments on commit a98d9e1

Please sign in to comment.