Extract a JSON value from a BASH script

find the simple bash script for extracting JSON value from this GitHub:

https://gist.github.com/cjus/1047794

function jsonValue() {
KEY=$1
num=$2
awk -F”[,:}]” ‘{for(i=1;i<=NF;i++){if($i~/'$KEY'\042/){print $(i+1)}}}' | tr -d ‘”‘ | sed -n ${num}p
}

Leave a Comment