diff options
| author | Tom Christie | 2012-09-20 13:19:43 +0100 |
|---|---|---|
| committer | Tom Christie | 2012-09-20 13:19:43 +0100 |
| commit | 87dae4d8549c02fa9a57adb3bb876d249dae1f79 (patch) | |
| tree | f3cf967490b79045ddf2be03e1e2ecebb23f58eb /djangorestframework/utils/encoders.py | |
| parent | 4b691c402707775c3048a90531024f3bc5be6f91 (diff) | |
| download | django-rest-framework-87dae4d8549c02fa9a57adb3bb876d249dae1f79.tar.bz2 | |
Remove old 'djangorestframework directories
Diffstat (limited to 'djangorestframework/utils/encoders.py')
| -rw-r--r-- | djangorestframework/utils/encoders.py | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/djangorestframework/utils/encoders.py b/djangorestframework/utils/encoders.py deleted file mode 100644 index 74876017..00000000 --- a/djangorestframework/utils/encoders.py +++ /dev/null @@ -1,38 +0,0 @@ -""" -Helper classes for parsers. -""" -import datetime -import decimal -from django.utils import simplejson as json -from djangorestframework.compat import timezone - - -class JSONEncoder(json.JSONEncoder): - """ - JSONEncoder subclass that knows how to encode date/time, - decimal types, and generators. - """ - def default(self, o): - # For Date Time string spec, see ECMA 262 - # http://ecma-international.org/ecma-262/5.1/#sec-15.9.1.15 - if isinstance(o, datetime.datetime): - r = o.isoformat() - if o.microsecond: - r = r[:23] + r[26:] - if r.endswith('+00:00'): - r = r[:-6] + 'Z' - return r - elif isinstance(o, datetime.date): - return o.isoformat() - elif isinstance(o, datetime.time): - if timezone and timezone.is_aware(o): - raise ValueError("JSON can't represent timezone-aware times.") - r = o.isoformat() - if o.microsecond: - r = r[:12] - return r - elif isinstance(o, decimal.Decimal): - return str(o) - elif hasattr(o, '__iter__'): - return [i for i in o] - return super(JSONEncoder, self).default(o) |
