tags:

views:

58

answers:

1

Hey,

I am using JSONEncoder with Django and to encode dictionaries containing Unicode strings (JSONEncoder.encode()). Resulting JSON is injected in the web page. The problem I am facing is that the resulting JSON contains u markers next to the strings and thus is not correctly interpreted in java script

e.g. { u"key" : u"value" }

How can i get rid of it?

Thanks

A: 

What you're working with there is the Python equivalent of your JSON object. To get it back into JSON you want to use dumps():

import json
mydict = { u"key" : u"value" }
print json.dumps(mydict)

Edit: I'm sorry this isn't exactly relevant to JSONEncoder, I will try to revise my answer.

jathanism