import json


def merge_json_files(output_file, *files):
    merged_data = dict()

    for file in files:
        with open(file, 'r', encoding='utf-8') as f2:
            data = json.load(f2)

        merged_data[file[:-5]] = data

    # 将合并后的数据写入新的JSON文件
    with open(output_file, 'w', encoding='utf-8') as output:
        json.dump(merged_data, output, ensure_ascii=False, indent=4)


if __name__ == "__main__":
    file0 = 'report-0423-0.json'
    file1 = 'report-0423-1.json'
    file2 = 'report-0423-2.json'
    file3 = 'report-0423-3.json'

    # output_ = './cases_dict-0423-0123.json'
    # output_ = './cases_dict-0423-123.json'
    # output_ = './cases_dict-0423-12.json'
    # output_ = './cases_dict-0423-13.json'
    # output_ = './cases_dict-0423-23.json'
    # output_ = './cases_dict-0423-01.json'
    # output_ = './cases_dict-0423-02.json'
    output_ = './cases_dict-0423-03.json'

    # 示例用法
    # merge_json_files(output_, file0, file1, file2, file3)
    # merge_json_files(output_, file1, file2, file3)
    # merge_json_files(output_, file1, file2)
    # merge_json_files(output_, file1, file3)
    # merge_json_files(output_, file2, file3)
    # merge_json_files(output_, file0, file1)
    # merge_json_files(output_, file0, file2)
    merge_json_files(output_, file0, file3)
