json_parser.sh

ShellMaster

Explorer

C40
C++40
C#40
Dart40
Go40
Java40
JavaScript40
Kotlin40
Objective-C40
Perl40
PHP40
Python40
R40
Ruby40
Rust40
Shell
Beginner10
Intermediate10
Advanced10
Expert5
Master5
parallel_batch.sh
trap_cleanup.sh
json_parser.sh
config_loader.sh
retry_wrapper.sh
Swift40
TypeScript40
json_parser.sh
Click to focus
1
2
3
4
5
6
7
8
9
10
11
parse_json() {
   local json="${1:?}"
   local query="${2:-.}"
   echo "$json" | jq -r "$query" 2>/dev/null || echo "null"
}
while IFS= read -r line; do
   id=$(parse_json "$line" '.id')
   [[ "$id" == "null" ]] && continue
   status=$(parse_json "$line" '.status // "pending"')
   curl -X POST "API/$id" -d "{\"status\":\"$status\"}"
done < <(curl -s "$URL" | jq -c '.items[]')
0WPM0%0:000/378(0%)|Ln 1, Col 1
UTF-8Shell

Related Exercises