FastLED 3.9.15
Loading...
Searching...
No Matches
json.cpp
Go to the documentation of this file.
1#include "fl/json.h"
2#include "fl/str.h"
3
4namespace fl {
5
6bool parseJson(const char *json, fl::JsonDocument *doc, Str *_error) {
7#if !FASTLED_ENABLE_JSON
8 if (_error) {
9 *_error = "JSON not enabled";
10 }
11 return false;
12#else
13 FLArduinoJson::DeserializationError error = deserializeJson(*doc, json);
14 if (error) {
15 if (_error) {
16 *_error = error.c_str();
17 }
18 return false;
19 }
20 return true;
21#endif
22}
23
24void toJson(const fl::JsonDocument &doc, Str *jsonBuffer) {
25#if !FASTLED_ENABLE_JSON
26 return;
27#else
28 serializeJson(doc, *jsonBuffer);
29#endif
30}
31
32} // namespace fl
Definition str.h:388
const char * c_str() const
Definition str.h:272
bool parseJson(const char *json, fl::JsonDocument *doc, Str *_error)
Definition json.cpp:6
void toJson(const fl::JsonDocument &doc, Str *jsonBuffer)
Definition json.cpp:24
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16