APPROACH 3: JSON Response Handling with FastLED's ideal JSON API This demonstrates fetch responses with automatic JSON parsing.
Definition at line 221 of file ClientReal.h.
221 {
222 FL_WARN(
"APPROACH 3: JSON Response handling with fl::json integration");
223
224
225
228 FL_WARN(
"SUCCESS [JSON Promise] HTTP fetch successful! Status: "
230
231
232
234 FL_WARN(
"DETECTED [JSON Promise] Response contains JSON data");
235
236
237
239
240
241
244 int slide_count = data[
"slideshow"][
"slides"].
size();
245
246 FL_WARN(
"JSON [Promise] Slideshow Author: " << slideshow_url);
247 FL_WARN(
"JSON [Promise] Slideshow Title: " << slideshow_title);
248 FL_WARN(
"JSON [Promise] Slide Count: " << slide_count);
249
250
251 if (data.
contains(
"slideshow") && data[
"slideshow"].contains(
"slides")) {
252 fl::json slides = data[
"slideshow"][
"slides"];
254
257 FL_WARN(
"JSON [Promise] First slide: " << first_slide_title <<
" (" << first_slide_type <<
")");
258 }
259 }
260
261
263
264 } else {
265 FL_WARN(
"INFO [JSON Promise] Response is not JSON format");
266
268 }
269 } else {
272
274 }
277
279 });
280
282}
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
bool is_array() const FL_NOEXCEPT
size_t size() const FL_NOEXCEPT
bool contains(size_t idx) const FL_NOEXCEPT
HTTP response class (unified interface)
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NOEXCEPT
Fill a range of LEDs with a solid color.
fl::task::Promise< Response > fetch_get(const fl::string &url, const FetchOptions &request)
HTTP GET request.
Representation of an 8-bit RGB pixel (Red, Green, Blue)
References fl::json::contains(), FastLED, fl::net::http::fetch_get(), fill_solid(), FL_WARN, fl::json::is_array(), leds, fl::task::Error::message, NUM_LEDS, and fl::json::size().
Referenced by loop().