Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
add datetime as a serializer for json
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramon Navarro Bosch committed Jan 2, 2017
1 parent d8377bf commit c70b48a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/plone.server/plone/server/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from zope.component import adapter
from zope.component import queryAdapter
from zope.interface import implementer
from datetime import datetime
# JSON Decoder
from zope.securitypolicy.settings import PermissionSetting

Expand All @@ -20,6 +21,9 @@ class PServerJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, complex):
return [obj.real, obj.imag]
if isinstance(obj, datetime):
serial = obj.isoformat()
return serial
try:
iterable = iter(obj)
except TypeError:
Expand Down

0 comments on commit c70b48a

Please sign in to comment.