#5553: JSON serializer imporperly serializes: datetime.datetime, datetime.time, float -----------------------+---------------------------------------------------- Reporter: pigletto | Owner: nobody Status: new | Component: Serialization Version: SVN | Keywords: json Stage: Unreviewed | Has_patch: 1 -----------------------+---------------------------------------------------- This bug was introduced after commiting patch for this ticket: http://code.djangoproject.com/ticket/4714 Original patch I've written was changed by commiter and this introduced some issues.
Problem is that now serializers/python.py uses smart_unicode(... , strings_only=True). Unfortunatelly smart_unicode only recogizes None, int and long as not strings. Because of this, datetime objects (as well as floats) are converted to strings. This causes that serializers/json.py -> DjangoJSONEncoder is useless. My, original implementation from #4714, uses function 'str_to_unicode' that converts only instances of basestring to unicode - so it works properly. I'm not sure why it was changed to 'smart_unicode', but if 'smart_unicode' should be used then 'force_unicode''s detection of strings has to be changed. Problem is with datetime.datetime, datetime.time, float and possibly Decimal. I've attached a patch with tests. -- Ticket URL: <http://code.djangoproject.com/ticket/5553> Django Code <http://code.djangoproject.com/> The web framework for perfectionists with deadlines --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---
