How to merge two json files in one with all info from 1 file and second file?
For example:
json1 = {"info": [{"id": "3", "book_id": "88" }]}
json2 = {"info": [{"id": "100", "book_id": "77" }]}
final_result = {
"info": [
{"id": "3", "book_id": "88" },
{"id": "100", "book_id": "77"}
]
}
Now it's just update it, and remove all info from first folder
import json
with open("folder1/1.json") as fin1:
data1 = json.load(fin1)
with open("folder2/1.json") as fin2:
data2 = json.load(fin2)
data1.update(data2)
with open("together.json", "w") as fin3:
json.dump(data1, fin3)