![jq:通配可能吗?](https://linux22.com/image/166289/jq%EF%BC%9A%E9%80%9A%E9%85%8D%E5%8F%AF%E8%83%BD%E5%90%97%EF%BC%9F%20.png)
我有以下 json 输出:
{ x0: { scores: { small, human readable }, payload: { huge data } }
{ x1: ... }
{ x2: ... }
...
{ xn: ... }
我想做的是,当我完成生成此报告时,将其放入文件和 jq 中,如下所示,使用伪代码:
{json content} | tee out.json | jq '.*.scores'
一个 glob 怎么会像这样使用 jq 呢?
答案1
jq '.| to_entries | map(.key,.value.scores)'
这是我想出的答案,但也许有一种全局风格的方法可以做到这一点。