Skip to content

Commit 15b3fe5

Browse files
committed
Create object serializer
1 parent 4b68252 commit 15b3fe5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

object-serializer/serializer.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import json
2+
3+
def serialize(object):
4+
5+
attribute_list = [attr for attr in dir(object) if not attr.startswith('__')]
6+
attributes_dict = {}
7+
8+
for attribute in attribute_list:
9+
attributes_dict[attribute] = object.__getattribute__(attribute)
10+
11+
return json.dumps(attributes_dict, indent=2)

0 commit comments

Comments
 (0)