i needed a bash regex to get the value for a given key in a json file. below is my solution.
json.sh
getJsonValue()
{
grep -Po '"'"$2"'"\s*:\s*"\K([^"]*)' $1
}
# example usage
# getJsonValue "json_file" "json_key"
json.sh
getJsonValue()
{
grep -Po '"'"$2"'"\s*:\s*"\K([^"]*)' $1
}
# example usage
# getJsonValue "json_file" "json_key"
1 comment:
thx
Post a Comment