[英]JQ combine json with key:value
I have two Json files我有两个 Json 文件
First:第一的:
''' { "KeyID": 7532173, "KeyDetails": "Level 12" } ''' ''' { "KeyID": 7532173, "KeyDetails": "Level 12" } '''
Second: ''' { "KeyID": 7532173, "Level": "Access Level" } '''第二:''' { "KeyID": 7532173, "Level": "Access Level" } '''
I would like to combine them matching the key:value pair of KeyId我想将它们与 KeyId 的键:值对相匹配
Please advise on how to proceed请告知如何进行
You could use if... then... else... end
, or more briefly, select
:您可以使用
if... then... else... end
,或更简单地说, select
:
jq -s 'select(.[0].KeyID==.[1].KeyID) | add' file1.json file2.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.