Questions tagged «jq»

jq是用于JSON数据的类似于sed的工具-您可以使用sq来轻松地对结构化数据进行切片,过滤,映射和转换,就像sed,awk,grep和friends可以让您玩文本一样。


9
使用jq或备用命令行工具比较JSON文件
是否有任何命令行实用程序可用于查找两个JSON文件是否相同,但字典内键和列表内元素顺序不变? 可以使用jq其他等效工具完成此操作吗? 例子: 这两个JSON文件是相同的 A: { "People": ["John", "Bryan"], "City": "Boston", "State": "MA" } B: { "People": ["Bryan", "John"], "State": "MA", "City": "Boston" } 但是这两个JSON文件不同: A: { "People": ["John", "Bryan", "Carla"], "City": "Boston", "State": "MA" } C: { "People": ["Bryan", "John"], "State": "MA", "City": "Boston" } 那将是: $ some_diff_command A.json …
78 json  diff  jq 

2
jq:打印对象中每个条目的键和值
我如何让jq像这样使用json: { "host1": { "ip": "10.1.2.3" }, "host2": { "ip": "10.1.2.2" }, "host3": { "ip": "10.1.18.1" } } 并生成以下输出: host1, 10.1.2.3 host2, 10.1.2.2 host3, 10.1.18.1 我对格式不感兴趣,只是无法弄清楚如何访问键名和值。
77 json  object  key  export-to-csv  jq 

2
使用jq的JSON中的Concat 2字段
我jq习惯于重新格式化我的JSON。 JSON字符串: {"channel": "youtube", "profile_type": "video", "member_key": "hello"} 想要的输出: {"channel" : "profile_type.youtube"} 我的命令: echo '{"channel": "youtube", "profile_type": "video", "member_key": "hello"}' | jq -c '. | {channel: .profile_type + "." + .member_key}' 我知道下面的命令将字符串连接起来。但是它不能以上述相同的逻辑工作: echo '{"channel": "youtube", "profile_type": "video", "member_key": "hello"}' | jq -c '.profile_type + "." + .member_key' 如何仅使用jq获得结果?
73 json  jq 

2
单行从jq获取输出
我得到以下输出:https : //stackoverflow.com/a/40330344 (.issues[] | {key, status: .fields.status.name, assignee: .fields.assignee.emailAddress}) 输出: { "key": "SEA-739", "status": "Open", "assignee": null } { "key": "SEA-738", "status": "Resolved", "assignee": "user2@mycompany.com" } 但是我需要解析每一行,但是就密钥组而言,很难确定哪个受让人对应哪个密钥。使用jq可以使一束成行吗? 预期产量: { "key": "SEA-739", "status": "Open", "assignee": null } { "key": "SEA-738", "status": "Resolved", "assignee": "user2@mycompany.com"} 要么 { "SEA-739", "Open", null } …
69 json  jq 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.