Consider a dict
of the form:
myDict = {'a': 'b'}
If I do json.dumps(myDict)
, I get '{"a": "b"}'
. So far so good.
What I'm trying to get is a string that looks like:
{\"a\":\"b\"}
(in order to sign an API request).
I've tried doing .replace('"', '\\"')
, which seemed to insert \\
.
What am I doing wrong?