鉴于以下 JSON,我正在尝试选择所有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"
}
}
]