Decode a versioned JSON object into an existing CRGB pixel buffer.
The document must use schema version 1 and contain exactly one RGB triplet per output pixel. Every channel must be an integer from 0 through 255. The complete document is validated before any output pixel is changed.
- Parameters
-
| document | JSON object produced by crgbToJson(). |
| pixels | Destination pixel buffer. |
- Returns
- true on success; false if the document is invalid. On failure,
pixels is left unchanged.
Definition at line 101 of file crgb_json.cpp.hpp.
101 {
103 return false;
104 }
105
106 const json versionJson = document["version"];
108 if (!versionJson.is_int() || versionJson.is_bool() || !version ||
109 *version != 1) {
110 return false;
111 }
112
113 const json encodedPixels = document[
"pixels"];
114 if (!encodedPixels.is_array() || encodedPixels.size() != pixels.
size()) {
115 return false;
116 }
117
118 for (size i = 0; i < encodedPixels.size(); ++i) {
120 return false;
121 }
122 }
123
124 for (size i = 0; i < encodedPixels.size(); ++i) {
126 }
127 return true;
128}
bool is_object() const FL_NO_EXCEPT
fl::optional< T > as() const FL_NO_EXCEPT
constexpr fl::size size() const FL_NO_EXCEPT
optional< CRGB > crgbJsonPixel(const json &value) FL_NO_EXCEPT
References fl::json::as(), FL_NO_EXCEPT, fl::json::is_array(), fl::json::is_bool(), fl::json::is_int(), and fl::json::size().