From cfed90c1096a92c4c9e622dfe2d55d892595b2ff Mon Sep 17 00:00:00 2001 From: Ido Ivri Date: Sun, 30 Oct 2016 19:47:28 +0200 Subject: initial commit of work done in DataHack --- libs/__init__.py | 1 + libs/json_tools.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100755 libs/__init__.py create mode 100755 libs/json_tools.py (limited to 'libs') 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 -- cgit v1.2.3