5 Useful jq commands to parse JSON on the CLI

Click for: original source

JSON has become the de facto standard data representation for the web. It’s lightweight, human-readable (in theory) and supported by all major languages and platforms. However, working on the CLI with JSON is still hard using traditional CLI tooling. By Fabian Keller.

Lucky, there is jq, a command-line JSON processor. jq offers a broad range of operations to transform and manipulate JSON based data structures from the command line. Looking at the documentation however reveals an overwhelmingly huge number of options, functions and things you can do with jq. This blog post shows 5 useful jq commands that you really need to know.

The article then describes:

  • The GitHub events API as example
  • Exploring the data structure
    • Extract a specific element from an array
    • Extract a specific key for all elements
    • Filter by specific value
    • Extracting all JSON paths
    • Deep text search

This blog post has shown some basic and advanced jq commands to explore and thrive with JSON on the command line. jq is very powerful and a reliable companion as soon as there is the first bit of JSON data on the CLI. Exciting!

[Read More]

Tags json big-data data-science programming software