这是3个JSON文件
File1
{
"component1": [
]
}
File2
{
"component2": [
]
}
File3
{
"component3": [
]
}
找不到将该JSON文件作为jq输出的jq命令行:
{
"components": {
"component1": [
],
"component2": [
],
"component3": [
]
}
}
非常感谢您的支持 最好的问候。
答案 0 :(得分:1)
从inputs
一次遍历输入对象,然后使用components
函数将其附加到reduce
jq -n 'reduce inputs as $d (.; .components += $d )' file{1..3}.json
答案 1 :(得分:1)
您可以简单地使用add
,例如
jq -s '{components: add}' file{1..3}.json
或:
jq -n '{components: [inputs]|add}' file{1..3}.json