Skip to content

Instantly share code, notes, and snippets.

View nate's full-sized avatar
🐯
rawr

N nate

🐯
rawr
View GitHub Profile
@IAmStoxe
IAmStoxe / loop-json.sh
Last active March 7, 2024 14:00
This example shows you how to utilize jq to loop bash script through an array of JSON values.
jsonData='[{"name": "name#1","value": "value#1"},{"name": "name#2","value": "value#2"}]'
for row in $(echo "${jsonData}" | jq -r '.[] | @base64'); do
_jq() {
echo "${row}" | base64 --decode | jq -r "${1}"
}
# OPTIONAL
# Set each property of the row to a variable
name=$(_jq '.name')
value=$(_jq '.value')