I was working with curl to get data from a api, and wanted to get a specific url for a specific name within an array. I got it working using jq, and will be demonstrating how I got it working.
The data:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
Getting the json objects inside the array “assets”:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
Data containing “k3s” under the “name” key::
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
Data that starts with “k3s” under the “name” key:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
Data with the exact name is “k3s”:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Getting only the “browser_download_url” value from the match:
1 2 |
|