I have thousands of text files containing multiple JSON objects, but unfortunately there is no delimiter between the objects. Objects are stored as dictionaries and some of
How about something like this:
import re import json jsonstr = open('test.json').read() p = re.compile( '}\s*{' ) jsonstr = p.sub( '}\n{', jsonstr ) jsonarr = jsonstr.split( '\n' ) for jsonstr in jsonarr: jsonobj = json.loads( jsonstr ) print json.dumps( jsonobj )