Last updated: Apr 4, 2024
Reading time·2 min
jq
is not installed by default on Windows, so if you try to use it, you'd get
the "'jq' is not recognized as an internal or external command" error.
The easiest way to install jq
is to use
Chocolatey.
To install jq
on Windows, if you have Chocolatey installed:
Click on the Search bar and type PowerShell.
Right-click on the PowerShell application and click "Run as administrator".
jq
and
curl.choco install jq -y choco install curl -y
To install Chocolatey:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco
to make sure Chocolatey is installed.Now that you have Chocolatey installed, run the following commands to install
jq
and curl
.
choco install jq -y choco install curl -y
Note that your shell should still be run using elevated permissions.
Make sure jq
is installed with the jq --version
command.
jq --version
Alternatively, you can install jq
using Git Bash.
jq
using Git BashTo install jq
using Git Bash, you have to open Git Bash as an administrator.
To run Git Bash as an administrator:
curl -L -o /usr/bin/jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe
Make sure jq
is installed with the jq --version
command.
jq --version
jq
on WindowsThe most common way to use jq
is to issue an HTTP request and pipe the
response to jq
to extract some information from it.
First, look at the response type of the API.
curl "https://randomuser.me/api/"
You can access the results
property by piping the response to jq
.
curl "https://randomuser.me/api/" | jq ".results"
You can access the first object in the list by accessing the element at index
0
.
curl "https://randomuser.me/api/" | jq ".results[0]"
You can then access specific properties on the response object.
curl "https://randomuser.me/api/" | jq ".results[0].email"
The command returns the email
property of the first object in the results
list.
You can learn more about the related topics by checking out the following tutorials: