Bin Chen Bin Chen - 1 year ago 210
JSON Question

python: single vs double quotes in JSON

My code:

import simplejson as json

s = "{'username':'dfdsfdsf'}" #1
#s = '{"username":"dfdsfdsf"}' #2
j = json.loads(s)

definition is wrong

definition is right

I was heard that in python that single double quote can be interchangable, can anyone explain this for me?

Answer Source

JSON syntax is not Python syntax. JSON requires double quotes for its strings.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download