mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-31 04:44:05 +02:00
change json validation
This commit is contained in:
@@ -8,8 +8,11 @@ if [ -f ${JSONTOCHECK} ]; then
|
|||||||
# Variables
|
# Variables
|
||||||
echo "Checking settings.json format"
|
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
|
# 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
|
# Check if all keys are still there, or add them
|
||||||
for KEYS in ${arr[@]}; do
|
for KEYS in ${arr[@]}; do
|
||||||
|
|||||||
Reference in New Issue
Block a user