REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
json.h
Go to the documentation of this file.
1// Copyright (c) 2024 anabrid GmbH
2// Contact: https://www.anabrid.com/licensing/
3//
4// SPDX-License-Identifier: MIT OR GPL-2.0-or-later
5
6// macro sugar for ArduinoJSON
7
8#include <ArduinoJson.h>
9
10// this probably needs conf.toJson(target.to<JsonObject>())
11#define JSON_CONVERT_SUGAR(type) \
12 inline void convertFromJson(JsonVariantConst src, type &conf) { conf.fromJson(src.as<JsonObjectConst>()); } \
13 inline void convertToJson(const type &conf, JsonVariant target) { conf.toJson(target.to<JsonObject>()); }
14
15#define JSON_GET(src, key) \
16 if (src.containsKey(#key)) \
17 key = src[#key];
18#define JSON_GET_AS(src, key, type) \
19 if (src.containsKey(#key)) \
20 key = src[#key].as<type>();
21#define JSON_SET(target, key) target[#key] = key;