| 278 | } |
| 279 | |
| 280 | void 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 | |
| 312 | void JsonConsole::writeOutput(const fl::string& message) FL_NOEXCEPT { |
| 313 | if (mWriteCallback) { |