

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Install cURL
incomplete
2: cURL Basics
incomplete
3: cURL POST Request
incomplete
4: Install jq
incomplete
5: jq Basics
incomplete
This lesson's interactive features are locked, please to keep using them
Once installed, you can use jq to parse and manipulate JSON data. Here's a simple example to get you started. Suppose you have a JSON file named user.json:
{
"name": "John",
"age": 30,
"city": "New York"
}
To extract the name field, you would use:
jq '.name' user.json
# "John"
jq is frequently used with cURL to parse JSON responses directly from HTTP requests. For example, to fetch JSON data from an API and extract a field we can use the object identifier index:
curl https://jsonplaceholder.typicode.com/users/1 | jq .username
# "Bret"
To get a field from each element in an array you can use the array/object value iterator .[], which can in turn be combined with the identifier index:
curl https://jsonplaceholder.typicode.com/users | jq '.[].username'
# "Bret"
# "Antonette"
# "Samantha"
# "Karianne"
# "Kamren"
# "Leopoldo_Corkery"
# "Elwyn.Skiles"
# "Maxime_Nienow"
# "Delphine"
# "Moriah.Stanton"
curl https://jsonplaceholder.typicode.com/users/1 | jq '.name, .email'
# "Leanne Graham"
# "Sincere@april.biz"
jq is extremely powerful. We won't cover every feature in this course, but it's a tool you should know about for the future.
https://api.boot.dev/v1/courses_rest_api/learn-http/issues
Run and submit the CLI tests.