所以我读了
jq
教程并使用
github
json
并提取了其他一些键的一些值
我想我理解语法的工作原理
。不幸的是,在Google上尝试使用它时,什么都不起作用
safe-browsing
json
回答下面是存储在变量中的完整响应(对来自
jq公司
教程):
echo "$safeb"
{
"matches": [
{
"threatType": "MALWARE",
"platformType": "ALL_PLATFORMS",
"threat": {
"url": "http://www.wittyvideos.com"
},
"cacheDuration": "300s",
"threatEntryType": "URL"
}
]
}
。。。这就是我所尝试的:
echo "$safeb" | jq '.matches.threatType'
jq: error (at <stdin>:13): Cannot index array with string "threatType"
echo "$safeb" | jq '.threatType'
null
echo "$safeb" | jq '.[] | .threatType'
jq: error (at <stdin>:13): Cannot index array with string "threatType"
echo "$safeb" | jq '.[] | {type: .threatType}'
jq: error (at <stdin>:13): Cannot index array with string "threatType"
提前谢谢。