使用命令行jq将json节点替换为另一个json文件 [英] replace json node with another json file with command line jq
本文介绍了使用命令行jq将json节点替换为另一个json文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个result.json
:
{
"Msg": "This is output",
"output": {}
}
和output.json
:
{
"type": "string",
"value": "result is here"
}
我想用整个文件output.json
替换result.json
中的output
字段
I want to replace output
field in result.json
with whole file output.json
as
{
"Msg": "This is output",
"output": {
"type": "string",
"value": "result is here"
}
}
和使用jq
命令行的想法?预先谢谢你.
and idea with jq
command line? Thank you in advance.
推荐答案
与Bertrand Martel的答案基本相同,但使用不同(且更短)的方法来读取两个文件.
Basically the same as Bertrand Martel's answer, but using a different (and shorter) approach to reading the two files.
jq -n 'input | .output = input' result.json output.json
这篇关于使用命令行jq将json节点替换为另一个json文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文