This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author beazley
Recipients beazley, georg.brandl
Date 2008-12-30.17:42:12
SpamBayes Score 1.135948e-08
Marked as misclassified No
Message-id <1230658934.34.0.991784557371.issue4785@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2008-12-30 17:42:14beazleysetrecipients: + beazley, georg.brandl
2008-12-30 17:42:14beazleysetmessageid: <1230658934.34.0.991784557371.issue4785@psf.upfronthosting.co.za>
2008-12-30 17:42:13beazleylinkissue4785 messages
2008-12-30 17:42:13beazleycreate