Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

jq select value from array

$
0
0

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")'

However response back is: jq: error (at <stdin>:11): Cannot index array with string "fileName"

What is the correct way to return the md5 value where the key fileName equals a certain argument?


Viewing all articles
Browse latest Browse all 657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>