cd /news/developer-tools/jq-to-filter-json-by-value · home topics developer-tools article
[ARTICLE · art-9798] src=gist.github.com ↗ pub= topic=developer-tools verified=true sentiment=· neutral

JQ to filter JSON by value

The article explains how to use the `jq` command-line tool to filter JSON data by a specific value. It provides the syntax `cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'` and notes that numeric values should not be enclosed in quotes within the `contains()` function. An example filters for records where the `_id` key equals the numeric value 611.

read1 min views19 publishedOct 24, 2016

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))' Example: To get json record having _id equal 611 cat my.json | jq -c '.[] | select( ._id | contains(611))' Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

── more in #developer-tools 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/jq-to-filter-json-by…] indexed:0 read:1min 2016-10-24 ·