json_encode() updated

[UPDATE] The link to the sourcecode now points to the dojango implementation, the dpaste one is gone.

Just in case someone is using json_encode() I wrote a while ago, I have updated the function due to updates in the latest Django dev version. Find the source here.

I have solved two problems here. One is that now lazy strings are used all over in Django, which this updates handles and detecting a list and a dictionary stumbled on subclasses of them.

4 Comments »

  1. zyegfryed said,

    April 18, 2008 at 12:12 pm

    Hi Wolfram,
    First, thank a lot for your contribution, that helps me a lot.
    I’m experimenting a problem with Decimal values, on python 2.5.1. I’ve got a “global name ‘Decimal’ is not defined” when tryinh to encode my data, that contains, as you can expect, some Decimal values.
    The workaround i find is to put this import statement at the top of your file :
    from decimal import Decimal
    Then, everything is fine !

  2. Ell Bee said,

    July 28, 2008 at 11:34 pm

    I\’m a newbie in Python and Django. I have some problem serializing some data in decimal format. I\’d like to try the json_encode you posted, but I\’m not sure where I can fit it into. Will I be able to use your code at the Django\’s shell prompt?
    Thanks,

  3. Free honest caring psychic. said,

    December 22, 2010 at 12:30 am

    Free honest caring psychic….

    Free honest caring psychic….

  4. uxebu.com » Blog Archiv » Ajax with dojango (dojo+django) said,

    August 3, 2011 at 7:25 pm

    [...] JSON data, all the data you stuff in there are returned to the client JSON encoded, it basically is json_encode as described here. If you have AJAX calls and want to return JSON data, this is the easiest way to do it and it comes [...]

RSS feed for comments on this post · TrackBack URL

Leave a Comment