jq:json对象的输出数组 |
您所在的位置:网站首页 › powershell定义数组 › jq:json对象的输出数组 |
说我有输入: { "name": "John", "email": "[email protected]" } { "name": "Brad", "email": "[email protected]" }我如何获得输出: [ { "name": "John", "email": "[email protected]" }, { "name": "Brad", "email": "[email protected]" } ]我试过两个: jq '[. | {name, email}]'和 jq '. | [{name, email}]'这两个都给了我输出 [ { "name": "John", "email": "[email protected]" } ] [ { "name": "Brad", "email": "[email protected]" } ]我也没有在文档中看到数组输出的选项,任何帮助表示赞赏 1> chepner..: 使用slurp模式: o --slurp/-s: Instead of running the filter for each JSON object in the input, read the entire input stream into a large array and run the filter just once. $ jq -s '.' 如果需要,您还可以将初始jq结果传送到`jq -s`.IE` ... | jq'.foo [] .bar'| jq -s` 您可以将过滤器包装在`[...]`中,而不是第二次运行`jq`; `... | jq'[.foo [].bar]'`. |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |