我有一个很大的 JSON 文件,我猜有 400 万个对象。每个顶层都有几个嵌套在其中的级别。我想将其拆分为多个文件,每个文件包含 10000 个顶级对象(保留每个文件内部的结构)。 jq应该可以做到吧?我不知道怎么办。
所以数据是这样的:
[{
"id": 1,
"user": {
"name": "Nichols Cockle",
"email": "[email protected]",
"address": {
"city": "Turt",
"state": "Thị Trấn Yên Phú"
}
},
"product": {
"name": "Lychee - Canned",
"code": "36987-1526"
}
}, {
"id": 2,
"user": {
"name": "Isacco Scrancher",
"email": "[email protected]",
"address": {
"city": "Likwatang Timur",
"state": "Biharamulo"
}
},
"product": {
"name": "Beer - Original Organic Lager",
"code": "47993-200"
}
}, {
"id": 3,
"user": {
"name": "Elga Sikora",
"email": "[email protected]",
"address": {
"city": "Wenheng",
"state": "Piedra del Águila"
}
},
"product": {
"name": "Parsley - Dried",
"code": "36987-1632"
}
}, {
"id": 4,
"user": {
"name": "Andria Keatch",
"email": "[email protected]",
"address": {
"city": "Arras",
"state": "Iracemápolis"
}
},
"product": {
"name": "Wine - Segura Viudas Aria Brut",
"code": "51079-385"
}
}, {
"id": 5,
"user": {
"name": "Dara Sprowle",
"email": "[email protected]",
"address": {
"city": "Huatai",
"state": "Kaduna"
}
},
"product": {
"name": "Pork - Hock And Feet Attached",
"code": "0054-8648"
}
}]
这是一个完整的对象:
{
"id": 1,
"user": {
"name": "Nichols Cockle",
"email": "[email protected]",
"address": {
"city": "Turt",
"state": "Thị Trấn Yên Phú"
}
},
"product": {
"name": "Lychee - Canned",
"code": "36987-1526"
}
}
每个文件都是指定数量的对象。