我在 Mac 上运行,并且有一个非常大的 .json 文件,其中包含超过 100k 个对象。
我想将文件分成许多文件(最好是 50-100)。
源文件
原始的 .json 文件是一个多维数组,看起来有点像这样:
[{
"id": 1,
"item_a": "this1",
"item_b": "that1"
}, {
"id": 2,
"item_a": "this2",
"item_b": "that2"
}, {
"id": 3,
"item_a": "this3",
"item_b": "that3"
}, {
"id": 4,
"item_a": "this4",
"item_b": "that4"
}, {
"id": 5,
"item_a": "this5",
"item_b": "that5"
}]
期望的输出
如果将其拆分为三个文件,我希望输出如下所示:
文件 1:
[{
"id": 1,
"item_a": "this1",
"item_b": "that1"
}, {
"id": 2,
"item_a": "this2",
"item_b": "that2"
}]
文件 2:
[{
"id": 3,
"item_a": "this3",
"item_b": "that3"
}, {
"id": 4,
"item_a": "this4",
"item_b": "that4"
}]
文件 3:
[{
"id": 5,
"item_a": "this5",
"item_b": "that5"
}]
任何想法将不胜感激。谢谢!