which command line utility can pretty-print a file with multiple lines (each encoded in json)
input file: msgs.json:
[1,{"6":7,"4":5}]
[2,{"6":7,"4":5}]
it seems that json.tool works only with a single JSON message
EDIT: modified json.tool to support multiple JSON msgs in the answer below
example usage:
python myjson.py msgs.json
[
1,
{
"4": 5,
"6": 7
}
]
[
2,
{
"4": 5,
"6": 7
}
]
In python do something like this:
import json
with open('msgs.json', 'r') as json_file:
for row in json_file:
data = json.loads(row)
print(json.dumps(data, sort_keys=True, indent=2, separators=(',', ': ')))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With