import json | |
def convert_jsonl_to_json(jsonl_file, json_file): | |
json_data = [] | |
with open(jsonl_file, 'r',encoding="utf-8") as file: | |
for line in file: | |
json_data.append(json.loads(line)) | |
with open(json_file, 'w',encoding="utf-8") as file: | |
json.dump(json_data, file) | |
# 使用示例 | |
jsonl_file = 'TriviaQA/6test.jsonl' | |
json_file = 'TriviaQA/6test.json' | |
convert_jsonl_to_json(jsonl_file, json_file) |