Goal: Merge JSON files into one big file
Background: I am using the code below taken from here Issue with merging multiple JSON files in Python
import json
import glob
result = []
for f in glob.glob("/Users/EER/Desktop/JSON_Combo/*.json"):
with open(f, "rb") as infile:
result.append(json.load(infile))
with open("merged_file.json", "wb") as outfile:
json.dump(result, outfile)
However, I get the following error:
JSONDecodeError: Extra data: line 2 column 1 (char 5733)
I checked Python json.loads shows ValueError: Extra data and JSONDecodeError: Extra data: line 1 column 228 (char 227) and ValueError: Extra Data error when importing json file using python but they are a bit different. A potential reason for the error seems to be that my .json files are a list of strings but I am not sure
Question: Any thoughts on how to fix this error?