I have thousands of text files containing multiple JSON objects, but unfortunately there is no delimiter between the objects.
The objects are stored as dictionaries and some of their fields are themselves objects. Each object might have a variable number of nested objects. Concretely, an object might look like this:
{field1: {}, field2: "some value", field3: {}, ...}
and hundreds of such objects are concatenated without a delimiter in a text file. This means that I can neither use json.load() nor json.loads().
Any suggestion on how I can solve this problem. Is there a known parser to do this?
This decodes your “list” of JSON Objects from a string:
The bonus here is that you play nice with the parser. Hence it keeps telling you exactly where it found an error.
Examples
Clean Solution (added later)
Examples