# Back slash in json

#1

Hello, probably this is a pure Python question but…
If I want to put “\’” into a json format from a Python code, my guess is you need to write “\\\\” in the code. Becasue “\\\\” is parsed to \\ in the json file and \\ in the json file is parsed to \ when it’s loaded. This is so far my understanding but seems wrong.

When I wrote

``````s="{\"Path\": \"A\\B\"}"
import json
print d
``````

I got this error.

``````Runtime error (ValueErrorException): Invalid \escape: 'B': line 1 column 13 (char 12)
``````

When I wrote

``````s="{\"Path\": \"A\\\\B\"}"
import json
print d
``````

I got

``````{'Path': 'A\\B'}
``````

This seems Okay at a first glance, but actually, “A\\B” is written in the json file, so when it’s decoded it’s should be parsed to “A\B”…

Am I missing something?

#2

This problem has been solved.
When I type

``````print d["Path"]
``````

I got

``````A\B
``````

So there was nothing problem… “A\\B” is before parsed…