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 <rep...@bugs.python.org>
<https://bugs.python.org/issue31553>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to