我有一个包含数组的非常大的JSON文件.是否可以使用jq将此数组拆分为几个固定大小的较小数组?假设我的输入是这样的:[1,2,3,4,5,6,7,8,9,10]我想把它分成3个元素的长块.所需的输出jq将是:
[1,2,3]
[4,5,6]
[7,8,9]
[10]
Run Code Online (Sandbox Code Playgroud)
实际上,我的输入数组有近300万个元素,都是UUID.
我有一个大的JSON文件,它是一个对象的对象,我想在对象键之后拆分成单独的文件名.是否可以使用jq或任何其他现成的工具来实现这一目标?
原始JSON采用以下格式
{ "item1": {...}, "item2": {...}, ...}
鉴于此输入,我想生成文件item1.json,item2.json等.
我有一个大的JSON文件,我猜测有400万个对象.每个顶级都有几个嵌套在里面的级别.我想将它分成多个10000个顶级对象的文件(保留每个内部的结构).jq应该能够做到这一点吗?我不知道怎么做.
所以这样的数据:
[{
"id": 1,
"user": {
"name": "Nichols Cockle",
"email": "ncockle0@tmall.com",
"address": {
"city": "Turt",
"state": "Th? Tr?n Yên Phú"
}
},
"product": {
"name": "Lychee - Canned",
"code": "36987-1526"
}
}, {
"id": 2,
"user": {
"name": "Isacco Scrancher",
"email": "iscrancher1@aol.com",
"address": {
"city": "Likwatang Timur",
"state": "Biharamulo"
}
},
"product": {
"name": "Beer - Original Organic Lager",
"code": "47993-200"
}
}, {
"id": 3,
"user": {
"name": "Elga Sikora",
"email": "esikora2@statcounter.com",
"address": {
"city": "Wenheng",
"state": "Piedra …Run Code Online (Sandbox Code Playgroud) 我有一个包含过多数据对象的 JSON 文件,格式如下:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-37.880859375,
78.81903553711727
],
[
-42.01171875,
78.31385955743478
],
[
-37.6171875,
78.06198918665974
],
[
-37.880859375,
78.81903553711727
]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-37.6171875,
78.07107600956168
],
[
-35.48583984375,
78.42019327591201
],
[
-37.880859375,
78.81903553711727
],
[
-37.6171875,
78.07107600956168
]
]
]
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想拆分大文件,以便每个特征对象都有自己的文件,其中包含其类型对象和特征(坐标)对象。所以基本上,我试图获得其中的许多:
{
"type": "FeatureCollection",
"features": [ …Run Code Online (Sandbox Code Playgroud)