How to filter JSON records by value with jq

Often when working with JSON in a Linux/Unix environment, it is nice to be able to filter records based on the values of certain fields. jq is a lightweight command line JSON processor that is very easy to use. jq offers an easy way to filter JSON records based on field values with the select() function.

The jq 'select()' function evaluates expressions that return true or false. Records for which the expression returns true will be output.

Here is an example of filtering all JSON records where the “first_name” field equals “Amelia”.

More examples of using jq can be found here

2 thoughts on “How to filter JSON records by value with jq”

    • Big Datums Post Author

      For this example file it would be:

      $ cat bdPerson_v1_1k.json | jq ‘select(.birthdate >= “1977-01-01”)’

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">