MCPcopy Create free account
hub / github.com/DataArcTech/ToG / jsonl_to_json

Function jsonl_to_json

tools/jsonl2json.py:3–8  ·  view source on GitHub ↗
(jsonl_file, json_file)

Source from the content-addressed store, hash-verified

1import json
2
3def jsonl_to_json(jsonl_file, json_file):
4 with open(jsonl_file, 'r') as infile:
5 with open(json_file, 'w') as outfile:
6 json_lines = infile.readlines()
7 json_list = [json.loads(line) for line in json_lines]
8 json.dump(json_list, outfile, indent=4)
9
10# 用法示例
11jsonl_to_json('ToG_cwq.jsonl', 'ToG_cwq.json')

Callers 1

jsonl2json.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected