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 NetTestReal.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 contains(size_t idx) const
fl::Json json() const
Response body parsed as JSON (JavaScript-like API)
const fl::string & status_text() const
HTTP status text (like JavaScript response.statusText)
int status() const
HTTP status code (like JavaScript response.status)
bool ok() const
Check if response is successful (like JavaScript response.ok)
bool is_json() const
Check if response appears to contain JSON content.
HTTP response class (unified interface)
void fill_solid(struct CRGB *targetArray, int numToFill, const struct CRGB &color)
Fill a range of LEDs with a solid color.
fl::promise< response > fetch_get(const fl::string &url, const fetch_options &request)
HTTP GET request.
Representation of an RGB pixel (Red, Green, Blue)
References fl::Json::contains(), FastLED, fl::fetch_get(), fl::fill_solid(), FL_WARN, fl::Json::is_array(), fl::response::is_json(), fl::response::json(), leds, fl::Error::message, NUM_LEDS, fl::response::ok(), fl::Json::size(), fl::response::status(), and fl::response::status_text().
Referenced by loop().