[New-bugs-announce] [issue31553] Extend json.tool to handle jsonlines (with a flag)

Eric Moyer report at bugs.python.org
Fri Sep 22 12:41:06 EDT 2017


New submission from Eric Moyer:

json.tool should have the ability to format jsonlines data. It is a very commonly used format in many industries. Right now when given jsonlines (for example):

    echo -e '{"ingredients":["frog", "water", "chocolate", "glucose"]} | python -m json.tool

Works. But:

    echo -e '{"ingredients":["frog", "water", "chocolate", "glucose"]}\n{"ingredients":["chocolate","steel bolts"]}' | python -m json.tool

Reports an error: "Extra data: line 2 column 1 - line 3 column 1 (char 58 - 100)"

I propose that the above behavior be retained but:

    echo -e '{"ingredients":["frog", "water", "chocolate", "glucose"]}\n{"ingredients":"chocolate","steel bolts"}' | python3.7 -m json.tool --jsonlines

Should print:
{
    "ingredients": [
        "frog",
        "water",
        "chocolate",
        "glucose"
    ]
}
{
    "ingredients": [
        "chocolate",
        "steel bolts"
    ]
}

If someone else agrees this is an appropriate enhancement, I can start work on a PR in a couple of weeks.

----------
components: Library (Lib)
messages: 302755
nosy: Eric Moyer
priority: normal
severity: normal
status: open
title: Extend json.tool to handle jsonlines (with a flag)
type: enhancement
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31553>
_______________________________________


More information about the New-bugs-announce mailing list