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 ZeD
Recipients ZeD
Date 2021-11-29.15:49:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1638200958.63.0.173460715414.issue45929@roundup.psfhosted.org>
In-reply-to
Content
It would be useful to let json.tool support empty rows during handling of json lines
generally speaking, this tolerance is already present in parsers like srsly and jsonlines

actual behavior:

# happy scenario
$ echo -e '{"foo":1}\n{"bar":2}' | python3.10 -mjson.tool --json-lines
{
    "foo": 1
}
{
    "bar": 2
}
$

# spurious EOL at EOF
$ echo -e '{"foo":1}\n{"bar":2}\n' | python3.10 -mjson.tool --json-lines
{
    "foo": 1
}
{
    "bar": 2
}
Expecting value: line 2 column 1 (char 1)
$

# two groups of "rows" in jsonl <- my current usecase
$ echo -e '{"foo":1}\n\n{"bar":2}' | python3.10 -mjson.tool --json-lines
{
    "foo": 1
}
Expecting value: line 2 column 1 (char 1)
$


my desired outcome is to preserve the EOLs, so to have something like:

# happy scenario
$ echo -e '{"foo":1}\n{"bar":2}' | python3.10 -mjson.tool --json-lines
{
    "foo": 1
}
{
    "bar": 2
}
$

# spurious EOL at EOF
$ echo -e '{"foo":1}\n{"bar":2}\n' | python3.10 -mjson.tool --json-lines
{
    "foo": 1
}
{
    "bar": 2
}

$

# two groups of "rows" in jsonl
$ echo -e '{"foo":1}\n\n{"bar":2}' | python3.10 -mjson.tool --json-lines
{
    "foo": 1
}

{
    "bar": 2
}
$
History
Date User Action Args
2021-11-29 15:49:18ZeDsetrecipients: + ZeD
2021-11-29 15:49:18ZeDsetmessageid: <1638200958.63.0.173460715414.issue45929@roundup.psfhosted.org>
2021-11-29 15:49:18ZeDlinkissue45929 messages
2021-11-29 15:49:18ZeDcreate