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 lukasz.langa
Recipients ZeD, bob.ippolito, ezio.melotti, lukasz.langa, rhettinger, serhiy.storchaka
Date 2021-12-10.23:59:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1639180743.41.0.10735023968.issue45929@roundup.psfhosted.org>
In-reply-to
Content
I agree with Serhiy that in general the fact that json.tool crashes here is useful: similarly to an exception in Python code, it can inform the user that some data they feed to json.tool is invalid.

At the same time, I find it a bit obnoxious that the current implementation doesn't allow for the *final character* of the input to be a newline (or "characters" in case of \r\n... but it should still only ignore *a single effective newline*).

I mean, if the user starts spewing newlines in the middle of the file... that might easily be an error. If the file ends with 5 empty lines, that might easily be an error. But, if the file really is:

{'line': 1, 'data': ...}\n
{'line': 2, 'data': ...}\n
{'line': 3, 'data': ...}\n

I think that should be pragmatically accepted by json.tool, especially since many text editors now add newline characters at file ends.
History
Date User Action Args
2021-12-10 23:59:03lukasz.langasetrecipients: + lukasz.langa, rhettinger, bob.ippolito, ezio.melotti, ZeD, serhiy.storchaka
2021-12-10 23:59:03lukasz.langasetmessageid: <1639180743.41.0.10735023968.issue45929@roundup.psfhosted.org>
2021-12-10 23:59:03lukasz.langalinkissue45929 messages
2021-12-10 23:59:03lukasz.langacreate