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.

2 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,

RSS feed for comments on this post · TrackBack URL

Leave a Comment