classification
Title: Adjacent escape character in json.load()
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Origami Tobiichi, serhiy.storchaka, xtreak
Priority: normal Keywords:

Created on 2019-08-25 13:41 by Origami Tobiichi, last changed 2019-08-30 14:26 by serhiy.storchaka. This issue is now closed.

Messages (5)
msg350456 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python triager) Date: 2019-08-25 13:46
Can you please add a description to explain the report?
msg350457 - (view) Author: Origami Tobiichi (Origami Tobiichi) Date: 2019-08-25 13:54
I tried something like this:
```python
print(r'{"foo": "\\\""}') 
print('{"foo": "\\\""}')
print(json.loads(r'{"foo":"\\\""}'))
```
On my machine it output like this:
```
{"foo": "\\\""}
{"foo": "\""}
{'foo': '\\"'}
```

But in most of online json parser, string `{"foo": "\\\""}` will be parsed as `{"foo":"\""}`

I'm not a specialist of JSON at all. If the standard of JSON hasn't said anything of it, please point it out in Python's Document at least.

When I ask my friend to run the code, he got the same result as me. And my friend is using lastest Arch Linux at that time(2019/08/26).

My python version: 3.7.4
System version: Linux 4.19.66-1-MANJARO
msg350458 - (view) Author: Origami Tobiichi (Origami Tobiichi) Date: 2019-08-25 14:00
I hope I have given enough infomations. And I'm not good at English, please forgive some of my spell wrong, thanks.
msg350465 - (view) Author: Origami Tobiichi (Origami Tobiichi) Date: 2019-08-25 15:15
I'm sorry that I remove you from list, actually it's my first time to commit an issue on there and I'm afraid I used it wrong.
msg350880 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-30 14:26
There is no a bug.

"\\\"" is the same as r"\\" -- a 2-charackter string consisting of a backslash character and a doublequote character. r"\\\"" is a different string, it contains 3 backslash characters.

>>> print("\\\"")
\"
>>> print(repr("\\\""))
'\\"'
History
Date User Action Args
2019-08-30 14:26:40serhiy.storchakasetstatus: open -> closed
resolution: not a bug
messages: + msg350880

stage: resolved
2019-08-30 10:02:28xtreaksetnosy: + serhiy.storchaka
2019-08-25 15:15:56Origami Tobiichisetnosy: + xtreak
messages: + msg350465
2019-08-25 14:00:28Origami Tobiichisetmessages: + msg350458
2019-08-25 13:54:38Origami Tobiichisetnosy: - xtreak

messages: + msg350457
title: About json.load(s -> Adjacent escape character in json.load()
2019-08-25 13:46:00xtreaksetnosy: + xtreak
messages: + msg350456
2019-08-25 13:41:13Origami Tobiichicreate