Forum Discussion
How to merge multiple JSON files into one
Hi, VoltesDev
Thanks for tharunkumarRTK reply. You can try following method to merge multiple JSON into one.
1. Use Python to read the JSON files, extract the relevant data, and merge them into a single file.
import json
# Create a list of all the JSON files that you want to combine.
json_files = ["file1.json", "file2.json", "file3.json"]
# Create an empty list to store the Python objects.
python_objects = []
# Load each JSON file into a Python object.
for json_file in json_files:
with open(json_file, "r") as f:
python_objects.append(json.load(f))
# Dump all the Python objects into a single JSON file.
with open("combined.json", "w") as f:
json.dump(python_objects, f, indent=4)
2. Use the jq command-line tool
jq -s . file1.json file2.json file3.json > combined.json
How to Combine Multiple JSON Files into a Single JSON File | by Abdelfatah MENNOUN | Medium
python 3.x - Merge multiple JSON files (more than two) - Stack Overflow
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum