Linux shell脚本之json解析
# 获取json字符串的值 # $1 json字符串 # $2 key function get_json_value() { local json=$1 local key=$2 local value=$(echo "${json}" | awk -F "[{,:}]" '{for(i=1;i<=NF;i++){if($i~"'${key}'"){print $(i+1)}}}' | sed 's/\"//g') echo ${value} } accessToken=`get_json_value "${body}" "accessToken"` echo $accessToken