Skip to content

Commit d051915

Browse files
committed
Change __getattribute__ to getattr
1 parent 5ec43ba commit d051915

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

object-serializer/serializer.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22

33
def serialize(object):
44

5+
''' Serializes a class object into json '''
56
attribute_list = [attr for attr in dir(object) if not attr.startswith('__')]
67
attributes_dict = {}
78

89
for attribute in attribute_list:
9-
attributes_dict[attribute] = object.__getattribute__(attribute)
10+
attributes_dict[attribute] = getattr(object, attribute)
1011

11-
return json.dumps(attributes_dict, indent=2)
12+
return json.dumps(attributes_dict, indent=2)
13+
14+
15+
def deserialize(content ,class_to_deserialize):
16+
json_content = json.loads(content)
17+
if type(json_content) == list:
18+
pass

0 commit comments

Comments
 (0)