Message407289
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
}
$ |
|
Date |
User |
Action |
Args |
2021-11-29 15:49:18 | ZeD | set | recipients:
+ ZeD |
2021-11-29 15:49:18 | ZeD | set | messageid: <1638200958.63.0.173460715414.issue45929@roundup.psfhosted.org> |
2021-11-29 15:49:18 | ZeD | link | issue45929 messages |
2021-11-29 15:49:18 | ZeD | create | |
|