From f350bfba784878f6ac3e7c4171b2a51acd85428a Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Mon, 14 Sep 2020 14:13:38 +0100 Subject: [PATCH] SITL: JSON: don't warn for none required sections --- libraries/SITL/SIM_JSON.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/SITL/SIM_JSON.cpp b/libraries/SITL/SIM_JSON.cpp index 8f9e95e786..c5758f8107 100644 --- a/libraries/SITL/SIM_JSON.cpp +++ b/libraries/SITL/SIM_JSON.cpp @@ -136,7 +136,10 @@ uint16_t JSON::parse_sensors(const char *json) const char *p = strstr(json, key.section); if (!p) { // we don't have this sensor - printf("Failed to find %s\n", key.section); + if (key.required) { + printf("Failed to find %s\n", key.section); + return 0; + } continue; } p += strlen(key.section)+1; @@ -147,9 +150,8 @@ uint16_t JSON::parse_sensors(const char *json) if (key.required) { printf("Failed to find key %s/%s\n", key.section, key.key); return 0; - } else { - continue; } + continue; } // record the keys that are found