I have the json as below, i need to get only the mail from the above json in bash script
value={"count":5,"users":[{"username":"asa","name":"asa Tran","mail":"[email protected]"},{"username":"qq","name":"qq Morris","mail":"[email protected]"},{"username":"qwe","name":"qwe Org","mail":"[email protected]"}]}
Output can be as
[email protected],[email protected],[email protected]
All the above need to be done in the bash script (.sh)
I have already tried with the array iteration as but of no use
for key in "${!value[@]}"
do
#echo "key = $key"
echo "value = ${value[$key]}"
done
Even i have tried with the array conversion as
alias json-decode="php -r 'print_r(json_decode(file_get_contents(\"php://stdin\"),1));'" value=$(curl --user $credentials -k $endPoint | json-decode)
Still i was not able to get the specific output.