School is a twelve-year jail sentence where bad habits are the only curriculum truly learned.
John Taylor Gatto
New forum topics
Recent comments
- you have to use source
3 days 17 hours ago - Why not just use this method
4 days 8 hours ago - Great!!!
1 week 3 hours ago - Really working with internet
1 week 10 hours ago - I haven't explored Puppet
5 weeks 7 hours ago - Wouldn't puppet be more
5 weeks 21 hours ago - I agree with the previous
11 weeks 1 day ago - how did this go when you
12 weeks 1 day ago - First off let me say thank
14 weeks 15 hours ago - You are my hero. :) Worked
18 weeks 23 hours ago
My little Django and Facebook project needed to do some JSON processing, time for using simplejson then.
My application will receive a string of JSON and transform it to a dictionary, pretty simple. Let's run a test first, starting with the Python shell, or better yet, iPython, and importing the module:
import simplejson
Now let's define a string using JSON notation and pass it to simplejson:
band = "{'name': 'Mando Diao', 'genre': 'rock and roll', 'bid': 19383}"
json = simplejson.loads(band)
And we get a ValueError exception. Let's try using simple quotes for enclosing the whole string and double quotes for the JSON keys and values:
band = '{"name": "Mando Diao", "genre": "rock and roll", "bid": 19383}'
json = simplejson.loads(band)
And there you go, no error now:
print json
{u'genre': u'rock and roll', u'bid': 19383, u'name': u'Mando Diao'}
I find a little strange that this problem happens as I've been using either type of quotes for most of my Python coding. Had you noticed this problem? I've checked simplejson's documentation and could not find anything related to this.
One last word, the new Python 2.6 includes a json module, which is a refactored simplejson. Neat.
Also visit
Other Resources
- Cloud based Task Management Software
- Top rated project scheduling software
- Daniel E Straus Aveta

Join the conversation
read the json spec at
read the json spec at json.org ... it requires double quotes for keys.
You might have gotten this
You might have gotten this sorted out by now, but the JSON format reuqires you to use "(double quotes)
If you are use this in Django
If you are use this in Django Framework! look this:
class JSONFormField(FeincmsJSONFormField):
def prepare_value(self, value):
if value or value == {}:
value = json.dumps(value)
return value
class JSONField(FeincmsJSONField)
...
def formfield(self, kwargs):
kwargs['form_class'] = JSONFormField
return super(FeincmsJSONField, self).formfield(kwargs)