Skip to content Skip to sidebar Skip to footer

Parse File With Multiple Json Objects In Python

I want to parse a file that contains multiple JSON objects that are not enclosed in an array and are separated only by a line break. The file has the following schema: {'id':1,'fir

Solution 1:

If every json object is on its own line, you should be able to do something like

with open('/path/to/file') as data:
    objects = [json.loads(line) for line in data]

Post a Comment for "Parse File With Multiple Json Objects In Python"