My JSON:
{
"projects": {
"api-client": {
"status": "false",
"when": "19-01-2016 12:54:47"
},
"api-admin": {
"status": "false",
"when": "19-01-2016 12:54:47"
},
"myweb": {
"status": "false",
"when": "19-01-2016 12:54:47"
}
}
}
Script:
JQ=$(which jq)
CACHE='cache.json'
PROJECT=("api-client" "api-admin" "myweb")
for PROJECT in ${PROJECTS[*]}; do
if [[ $(${JQ} -r ".projects.\"${PROJECT}\"" ${CACHE}) != null ]]; then
if [[ $(${JQ} -r ".projects.\"${PROJECT}\".status" ${CACHE}) == true ]]; then
local PROJECTDATE=$(${JQ} -r ".projects.\"${PROJECT}\".when" ${CACHE})
local STATUS="${COLOR_GREEN}Installed${CLEAR} on ${COLOR_YELLOW}${PROJECTDATE}${CLEAR}"
else
local STATUS="${COLOR_RED}Not installed${CLEAR}"
fi
echo -e "${CLEAR} - ${COLOR_CYAN}${PROJECT}${CLEAR} => ${STATUS}"
fi
done
Error: error: syntax error, unexpected QQSTRING_START, expecting IDENT .projects."api-client" ^ 1 compile error error: syntax error, unexpected QQSTRING_START, expecting IDENT .projects."api-client".status ^ 1 compile error - api-client => Not installed
Can someone please help debug my script?