I need to work with a lot of json strings as byte objects that look like this:
json_string = b'{"a":"1","b":"2","c":"abc=\"d\""}'.decode('utf8')
when I put them through json.loads()
json_object = json.loads(json_string)
it fails because the double quotes are not correctly escaped. How do I replace the \
with a \\
and is there another option than replacing all \
with \\
? Because at other positions in the string it might be unwanted to replace them. The real json strings
are longer and more complex than in the example here.
I use python 3.5