【发布时间】:2021-10-18 18:54:44
【问题描述】:
伙计们。任务是:获取所有唯一键和这些键的匹配值列表,然后将它们包装在 {}
json 看起来像:
{
"sepalLength": 5,
"sepalWidth": 3.3,
"petalLength": 1.4,
"petalWidth": 0.2,
"species": "setosa"
},
{
"sepalLength": 7,
"sepalWidth": 3.2,
"petalLength": 4.7,
"petalWidth": 1.4,
"species": "versicolor"
},
{
"sepalLength": 6.4,
"sepalWidth": 3.2,
"petalLength": 4.5,
"petalWidth": 1.5,
"species": "versicolor"
},
...
结果必须是这样的:
{
"species": ["setosa", "setosa", ...],
"petalWidth": [1.2, ...],
...
}
【问题讨论】:
-
您尝试过什么? idownvotedbecau.se/noattempt
-
哦,对不起,我是新来的,我不知道这个规则。我试过这个:jq'。作为 $glob | foreach [[.[] |键[]] | unique[]][] as $item (0; .+1; "(.) - ($glob[$item])")' iris.json 但是发生了错误。我以前没用过jq,所以犯了愚蠢的错误)
-
无铅。欢迎来到 SO。下次,编辑您的问题以显示代码,不要放在评论中。