I have this string:
> x.data
u'{u"orderNumber": u"69898327728", u"resultingTrades": []}'
How can I convert it to json? This doesn't work:
> import json
> json.dumps(x.data)
'"{u\\"orderNumber\\": u\\"69898327728\\", u\\"resultingTrades\\": []}"'
It just creates a long string. I need to convert it to json so that later I can do json.loads and access the keys in the dict, like this:
y = json.loads(x.data)["orderNumber"]
ast.literal_eval()to convert it to a dictionary directly. You don't need to go through JSON at all.