MCPcopy Create free account
hub / github.com/FastLED/FastLED / updateComponentMapping

Method updateComponentMapping

src/platforms/shared/ui/json/json_console.cpp.hpp:280–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280void JsonConsole::updateComponentMapping(const char* jsonStr) FL_NOEXCEPT {
281 if (!jsonStr) {
282 return;
283 }
284
285 // Parse using new json
286 auto doc = fl::json::parse(jsonStr);
287 if (doc.is_null()) {
288 return; // Invalid JSON
289 }
290
291 // Clear existing mapping
292 mComponentNameToId.clear();
293
294 // Parse component array and build name->ID mapping
295 if (doc.is_array()) {
296 // Iterate through array elements
297 for (size_t i = 0; i < doc.size(); i++) {
298 auto component = doc[i];
299 // Check if component has name and id fields
300 if (component.contains("name") && component.contains("id")) {
301 auto nameOpt = component["name"].as_string();
302 auto idOpt = component["id"].as_int();
303
304 if (nameOpt.has_value() && idOpt.has_value()) {
305 mComponentNameToId[*nameOpt] = static_cast<int>(*idOpt);
306 }
307 }
308 }
309 }
310}
311
312void JsonConsole::writeOutput(const fl::string& message) FL_NOEXCEPT {
313 if (mWriteCallback) {

Callers 1

FL_TEST_FILEFunction · 0.80

Calls 8

is_nullMethod · 0.45
clearMethod · 0.45
is_arrayMethod · 0.45
sizeMethod · 0.45
containsMethod · 0.45
as_stringMethod · 0.45
as_intMethod · 0.45
has_valueMethod · 0.45

Tested by

no test coverage detected