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

Function formatJsonResponse

src/fl/remote/transport/serial.cpp.hpp:12–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10namespace fl {
11
12fl::string formatJsonResponse(const fl::json& response, const char* prefix) {
13 // Use sstream to minimize allocations
14 fl::sstream ss;
15
16 // Add prefix if provided
17 if (prefix && prefix[0] != '\0') {
18 ss << prefix;
19 }
20
21 // Serialize to compact JSON
22 fl::string jsonStr = response.to_string();
23
24 // Stream copy with inline filtering (replace newlines with spaces)
25 for (size_t i = 0; i < jsonStr.size(); ++i) {
26 char c = jsonStr[i];
27 ss << ((c == '\n' || c == '\r') ? ' ' : c);
28 }
29
30 return ss.str();
31}
32
33} // namespace fl

Callers 5

createSerialResponseSinkFunction · 0.85
ble_esp32.cpp.hppFile · 0.85
FL_TEST_FILEFunction · 0.85
printJsonRawFunction · 0.85
printStreamRawFunction · 0.85

Calls 3

to_stringMethod · 0.45
sizeMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected