The JSON variable is parsed in the shell to obtain the value corresponding to the key

The JSON variable is parsed in the shell to obtain the value of value1 corresponding to key1, as follows:

s="{"key1":"abc","key2":"value2","key3":"value3"}"
parse_json(){
echo "${1//\"/}" | sed "s/.*$2:\([^,}]*\).*/\1/"
}
value=$(parse_json $s "key1")
echo $value

----------------------
output abc

Read More: