--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_utils/json.py Mon Sep 17 16:14:22 2018 +0200
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+import json
+
+from datetime import date, datetime
+
+# import interfaces
+
+# import packages
+
+
+def default_json_encoder(obj):
+ if isinstance(obj, (date, datetime)):
+ return obj.isoformat()
+ else:
+ return obj
+
+
+json._default_encoder = json.JSONEncoder(skipkeys=False,
+ ensure_ascii=True,
+ check_circular=True,
+ allow_nan=True,
+ indent=None,
+ separators=None,
+ default=default_json_encoder)