I am trying to merge the multiple json file into one which looks like this:
file1: [[a,b],[c,d],[e,f]]
file2: [[g,h],[i,f],[k,l]]
file3: [[m,n],[o,p],[q,r]]
I am using the below code to merge the files:
data = []
for f in glob.glob("*.json"):
with open(f,) as infile:
data.append(json.load(infile))
with open("merged_file.json",'w') as outfile:
json.dump(data, outfile)
out: [[[a,b],[c,d],[e,f]],[[g,h],[i,f],[k,l]],[[m,n],[o,p],[q,r]]]
But what I want is:
[[a,b],[c,d],[e,f],[g,h],[i,f],[k,l],[m,n],[o,p],[q,r]]
Instead of having separated lists, I wanted them in one list.