change json validation

This commit is contained in:
Alexandre
2021-10-31 14:39:32 +01:00
parent 7f6993219e
commit 429a1b0e7b

View File

@@ -8,8 +8,11 @@ if [ -f ${JSONTOCHECK} ]; then
# Variables
echo "Checking settings.json format"
# Check if json file valid or not
jq -reM '""' <<<${JSONTOCHECK} 1>/dev/null || (bashio::log.fatal "Settings.json structure is abnormal, restoring options from scratch" && cp ${JSONSOURCE} ${JSONTOCHECK})
# Get the default keys from the original file
mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE}) || (bashio::log.fatal "Settings.json structure is abnormal, restoring options from scratch" && cp ${JSONSOURCE} ${JSONTOCHECK})
mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE})
# Check if all keys are still there, or add them
for KEYS in ${arr[@]}; do