[英]Merge json files - Concatenate into a single dict json file
here are 3 JSON files这是 3 个 JSON 文件
File1文件 1
{
"component1": [
]
}
File2文件 2
{
"component2": [
]
}
File3文件 3
{
"component3": [
]
}
Don't find the jq command line that would give this JSON file as jq output:找不到可以将此 JSON 文件作为 jq 输出的 jq 命令行:
{
"components": {
"component1": [
],
"component2": [
],
"component3": [
]
}
}
Many thanks for your support Best Regards.非常感谢您的支持 最好的问候。
从inputs
迭代输入对象一次,并使用reduce
函数将其附加到components
jq -n 'reduce inputs as $d (.; .components += $d )' file{1..3}.json
You can simply use add
, eg您可以简单地使用
add
,例如
jq -s '{components: add}' file{1..3}.json
or:或者:
jq -n '{components: [inputs]|add}' file{1..3}.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.