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/json_tools.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 libs/json_tools.py (limited to 'libs/json_tools.py') 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