From cee796c705f23d5adc11fe228700ff12474978f7 Mon Sep 17 00:00:00 2001 From: Rune Harlyk Date: Tue, 9 Jul 2024 20:07:32 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=84=20Formats=20JsonUtils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- esp32/lib/ESP32-sveltekit/JsonUtils.h | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/esp32/lib/ESP32-sveltekit/JsonUtils.h b/esp32/lib/ESP32-sveltekit/JsonUtils.h index 067adae..6aa6c85 100644 --- a/esp32/lib/ESP32-sveltekit/JsonUtils.h +++ b/esp32/lib/ESP32-sveltekit/JsonUtils.h @@ -19,29 +19,22 @@ #include #include -class JsonUtils -{ -public: - static void readIP(JsonObject &root, const String &key, IPAddress &ip, const String &def) - { +class JsonUtils { + public: + static void readIP(JsonObject &root, const String &key, IPAddress &ip, const String &def) { IPAddress defaultIp = {}; - if (!defaultIp.fromString(def)) - { + if (!defaultIp.fromString(def)) { defaultIp = INADDR_NONE; } readIP(root, key, ip, defaultIp); } - static void readIP(JsonObject &root, const String &key, IPAddress &ip, const IPAddress &defaultIp = INADDR_NONE) - { - if (!root[key].is() || !ip.fromString(root[key].as())) - { + static void readIP(JsonObject &root, const String &key, IPAddress &ip, const IPAddress &defaultIp = INADDR_NONE) { + if (!root[key].is() || !ip.fromString(root[key].as())) { ip = defaultIp; } } - static void writeIP(JsonObject &root, const String &key, const IPAddress &ip) - { - if (IPUtils::isSet(ip)) - { + static void writeIP(JsonObject &root, const String &key, const IPAddress &ip) { + if (IPUtils::isSet(ip)) { root[key] = ip.toString(); } }