I have the following JSON file with example values:
{
"files": [{
"fileName": "FOO",
"md5": "blablabla"
}, {
"fileName": "BAR",
"md5": "alaldlafj"
}]
}
Now what I want is to return the md5 value where for example the fileName is "FOO". For this I have the following statement in jq
:
cat <file>.json | jq '.[] | select(.fileName=="FOO")'
然而,回应是:jq: error (at <stdin>:11): Cannot index array with string "fileName"
在密钥文件名等于某个参数的情况下,返回MD5值的正确方式是什么?