New submission from David M. Beazley <beaz...@users.sourceforge.net>:
The strict parameter to JSONDecoder() is undocumented and is confusing because someone might assume it has something to do with the encoding parameter or the general handling of parsing errors (which it doesn't). As far as I can determine by reading the source, strict determines whether or not JSON strings are allowed to contain literal newlines in them or not. For example (note: loads() passes its parameters to JSONDecoder): >>> s = '{"test":"Hello\nWorld"}' >>> print(s) {"test":"Hello World"} >>> json.loads(s) Traceback (most recent call last): ... File "/tmp/lib/python3.0/json/decoder.py", line 159, in JSONString return scanstring(match.string, match.end(), encoding, strict) ValueError: Invalid control character at: line 1 column 14 (char 14) >>> json.loads(s,strict=False) {'test': 'Hello\nWorld'} >>> Note in this last example how the result has the literal newline embedded in it when strict is set False. ---------- assignee: georg.brandl components: Documentation messages: 78550 nosy: beazley, georg.brandl severity: normal status: open title: json.JSONDecoder() strict argument undocumented and potentially confusing type: behavior versions: Python 2.6, Python 3.0 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4785> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com