bpo-31553: add --json-lines option to json.tool by hongweipeng · Pull Request #10051 · python/cpython
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of loading all lines and only later dump all objects, it may be better to: load on object, dump it, then load the second object, etc.
The behavior difference is that first JSONs are written into outfile if they are valid, but if the last one is invalid. With the current code, it's all-or-nothing. Maybe it's done on purpose?
The other advantage of working on a single object is to reduce the memory footprint when working with large JSON files.