JSON and Web Requests
curl fetches URLs and jq filters JSON. Together they script APIs. jq works on local text without a network, so the example parses a JSON string.
Example
echo '{"name":"Ada","skills":["bash","git"]}' | jq -r ".name"
echo '{"name":"Ada","skills":["bash","git"]}' | jq -r ".skills[]"
# curl -s https://api.example.com/users | jq ".[0].id"Result
Ada bash git
Exercise
Filter JSON.
echo "$j" | ".name"
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.