#!/usr/bin/python3 # import sys import json output = [] with open(sys.argv[1], 'r') as rh: i = 1 for line in rh.readlines(): try: data = json.loads(line) except json.decoder.JSONDecodeError as e: print("ERROR in Line %d" % i) raise output.append(json.loads(line)) i += 1 print(json.dumps(output, indent=4))