给定以下 JSON,我想选择所有的
我尝试传递 jq 类似
command
元素。我的问题是 "checkout"
字符串干扰了我选择所有 "run"
字典的过程。我尝试传递 jq 类似
.[].run.command
的内容,但我一直收到错误信息:jq: error (at <stdin>:33): Cannot index string with string "run"
如何排除选取 "checkout"
字符串?[
"checkout",
{
"run": {
"command": "pip install cfn-lint pycodestyle pyflakes",
"name": "Install Dependencies"
}
},
{
"run": {
"command": "find stacks -type f -name \"*.yml\" -exec cfn-lint -i E3016 -i E3012 -i E1029 --template {} \\; | tee -a output.txt",
"name": "Run cfn-lint"
}
},
{
"run": {
"command": "find stacks -type f -name \"*.py\" -exec pyflakes {} \\; | tee -a output.txt",
"name": "Run pyflakes"
}
},
{
"run": {
"command": "pycodestyle --show-source --show-pep8 --ignore=E501,W605 stacks/src | tee -a output.txt",
"name": "Run pycodestyle"
}
},
{
"run": {
"command": "if [[ -s output.txt ]]; then cat output.txt; exit 1; fi",
"name": "Exit if there are validation warnings/errors"
}
}
]