I have json as shown below, I need to get only mail from the above json in bash script
values = {"counter": 5, "users": [{"username": "ac", "name": "ac Tran" "mail": " asa@xyz.com "}, {"username" : "sq. sq.", "name": "sq. Morris" "mail": " qq@xyz.com "}, {"username": "QWE", "name": "QWE Org", " mail ":" qwe@xyz.com "}]}
The output may be like
mail=asa@xyz.com,qq@xyz.com,qwe@xyz.com
All of the above must be done in a bash script (.sh)
I already tried with iterating the array but not using
for key in "${!value[@]}"
do
echo "value = ${value[$key]}"
done
Even I tried with 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)
However, I could not get a specific conclusion.
source
share