Django

Code

Changeset 3795

Show
Ignore:
Timestamp:
09/22/06 08:26:07 (2 years ago)
Author:
mtredinnick
Message:

Fixed #2515 -- Allow passing of options to JSON serializer. Thanks, nesh.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/AUTHORS

    r3794 r3795  
    113113    Robin Munn <http://www.geekforgod.com/> 
    114114    Nebojša Dorđević 
     115    nesh 
    115116    Sam Newman <http://www.magpiebrain.com/> 
    116117    Neal Norwitz <nnorwitz@google.com> 
  • django/trunk/django/core/serializers/json.py

    r3671 r3795  
    1717    """ 
    1818    def end_serialization(self): 
    19         simplejson.dump(self.objects, self.stream, cls=DateTimeAwareJSONEncoder
     19        simplejson.dump(self.objects, self.stream, cls=DateTimeAwareJSONEncoder, **self.options
    2020         
    2121    def getvalue(self): 
  • django/trunk/docs/serialization.txt

    r3237 r3795  
    9797.. _simplejson: http://undefined.org/python/#simplejson 
    9898 
     99Notes For Specific Serialization Formats 
     100---------------------------------------- 
     101 
     102json 
     103~~~~ 
     104 
     105If you are using UTF-8 (or any other non-ASCII encoding) data with the JSON 
     106serializer, you must pass ``ensure_ascii=False`` as a parameter to the 
     107``serialize()`` call. Otherwise the output will not be encoded correctly. 
     108 
     109For example:: 
     110 
     111    json_serializer = serializers.get_serializer("json") 
     112    json_serializer.serialize(queryset, ensure_ascii=False, stream=response) 
     113 
    99114Writing custom serializers 
    100115``````````````````````````