Hi all,

We've switched internally from json to simplejson. Our 1.5 release notes

You can safely change any use of django.utils.simplejson to json

I just found a very big difference between json and simplejson

>>> simplejson.loads('{"x":"y"}')
{'x': 'y'}

>>> json.loads('{"x":"y"}')
{u'x': u'y'}

i.e. simplejson returns bytestrings if the string is ASCII (it returns
unicode objects otherwise), while json returns unicode objects always.

This was, unfortunately, a very unfortunate design decision on the part
of simplejson - json is definitely correct here - and a very big change
in semantics. It led to one very difficult to debug error for me already.

So, this is a shout out to other people to watch out for this, and a
call for ideas on what we can do to mitigate the impact of this. It's
likely to crop up in all kinds of horrible places, deep in libraries
that you can't do much about. In my case I was loading config, including
passwords, from a config file in JSON, and the password was now
exploding inside smtplib because it was a unicode object.

Yuck. Ideas?


    Variables won't, constants aren't.

Luke Plant || http://lukeplant.me.uk/

You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to