How can I check if a certain string is in a JSON array?
JSON array:
["domain","password","root","url","user"]
I need to check if "domain", "password", "root", "url", "user" are inside the array or not.
ad=("domain" "password" "root" "url" "user")
keys=$(kubectl get secret ssss --context rrrr -n test -o jsonpath=\{$.data\} | jq -c 'keys')
for value in "${keys[@]}"; do
key+=($value)
done
#echo ${key[@]}
for string in ${ad[@]}; do
if [ "$key"== "$string" ]; then
echo ${string[@]}
echo ${key[@]}
fi
done