I have a json file with multiple json objects (each object can be a multiple line json) Example:
{"date": "2022-11-29", "runs": [{"23597": 821260}, {"23617": 821699}]}
{"date": "2022-11-30", "runs": [{"23597": 821269}, {"23617": 8213534}]}
Note that indeed this is not valid JSON as whole file (and hence regular "read JSON in Python" code fails, expected), but each individual "fragment" is complete and valid JSON. It sounds like file was produced by some logging tool that simply appends the next block as text to the file.
As expected, regular way of reading that I have tried with the below snippet fails:
with open('run_log.json','r') as file:
d = json.load(file)
print(d)
Produces expected error about invalid JSON:
JSONDecodeError: Extra data: line 3 column 1 (char 89)
How can I solve this, possibly using the json module? Ideally, I want to read the json file and get the runs list for only a particular date (Ex : 2022-11-30), but just being able to read all entries would be enough.