diff options
author | Ido Ivri <ido@zencity.io> | 2016-10-30 19:47:28 +0200 |
---|---|---|
committer | Ido Ivri <ido@zencity.io> | 2016-10-30 19:47:28 +0200 |
commit | cfed90c1096a92c4c9e622dfe2d55d892595b2ff (patch) | |
tree | df8a996130a7ad199ede2312412d798147576d84 /libs |
initial commit of work done in DataHack
Diffstat (limited to 'libs')
-rwxr-xr-x | libs/__init__.py | 1 | ||||
-rwxr-xr-x | libs/json_tools.py | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/libs/__init__.py b/libs/__init__.py new file mode 100755 index 0000000..c2514b7 --- /dev/null +++ b/libs/__init__.py @@ -0,0 +1 @@ +from libs.json_tools import JsonSerializable
\ No newline at end of file diff --git a/libs/json_tools.py b/libs/json_tools.py new file mode 100755 index 0000000..5c26b24 --- /dev/null +++ b/libs/json_tools.py @@ -0,0 +1,12 @@ +import json + + +class JsonSerializable(object): + def __repr__(self): + return str(self.to_json()) + + def to_json(self): + return json.dumps(self.__dict__, ensure_ascii=False) + + def to_dict(self): + return self.__dict__
\ No newline at end of file |