So I have to import a json file in an identical format shown below:
{
"name": "bob"
}
{
"name": "sarah"
}
This is the function I am trying to use to open it:
def read_json_file(file):
with open(file, "r") as r:
response = json.load(r)
return response
I am getting this error when trying to load it:
json.decoder.JSONDecodeError: Extra data: line 4 column 1 (char 22)
There's no way for me to fix the json data as the file is quite large. I need a way to work around it to parse through each dictionary.
I have already tried the method when this question was asked:
Python json.loads shows ValueError: Extra data
I tried changing my function to match the top answer:
response = json.dumps(r)
That however brought upon this error:
TypeError: Object of type TextIOWrapper is not JSON serializable
Any help would be appreciated on this.