[issue34933] json.dumps serializes double quotes incorrectly
Juozas Masiulis
report at bugs.python.org
Mon Oct 8 10:11:26 EDT 2018
New submission from Juozas Masiulis <compositum at gmail.com>:
currently python behaves like this:
>>> import json
>>> a={'a': '//a[@asdf="asdf"]'}
>>> json.dumps(a)
'{"a": "//a[@asdf=\\"asdf\\"]"}'
this behaviour is incorrect.
the resulting string should be '{"a": "//a[@asdf=\"asdf\"]"}'
The difference is that double quotes inside double quotes are escaped twice instead of once.
compare it to behaviour in javascript:
> var a = {'a': '//a[@asdf="asdf"]'}
undefined
JSON.stringify(a)
"{"a":"//a[@asdf=\"asdf\"]"}"
----------
messages: 327352
nosy: Juozas.Masiulis
priority: normal
severity: normal
status: open
title: json.dumps serializes double quotes incorrectly
type: behavior
versions: Python 2.7, Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34933>
_______________________________________
More information about the Python-bugs-list
mailing list