Convert unicode json to normal json in python

后端 未结 4 1269
谎友^
谎友^ 2020-12-19 02:28

I got the following json: {u\'a\': u\'aValue\', u\'b\': u\'bValue\', u\'c\': u\'cValue\'} by doing request.json in my python code. Now, I want to c

4条回答
  •  醉话见心
    2020-12-19 03:02

    {u'a': u'aValue', u'b': u'bValue', u'c': u'cValue'} is a dictionary which you are calling as unicode json. Now, in your language if you want a regular json from this then just do something like this:

    x={u'a': u'aValue', u'b': u'bValue', u'c': u'cValue'}
    y=json.dumps(x)
    print y
    

    The output will be {"a": "aValue", "c": "cValue", "b": "bValue"}

提交回复
热议问题