FastLED 3.10.8
Loading...
Searching...
No Matches

◆ to_string_native()

fl::string fl::json::to_string_native ( ) const

Definition at line 1304 of file json.cpp.hpp.

1304 {
1305 if (!mValue) {
1306 return "null";
1307 }
1308
1309 // Use fl::deque for memory-efficient JSON serialization
1310 fl::deque<char> json_chars;
1311
1312 // Use the visitor to serialize the value recursively
1313 SerializerVisitor visitor{json_chars};
1314 visitor.serialize_value(mValue.get());
1315
1316 // Convert deque to fl::string. With FastLED #3270 the deque is chunked,
1317 // so its storage is no longer contiguous -- treating `&json_chars[0]`
1318 // as a buffer would walk off the first chunk. Reserve + per-element
1319 // append is correct for the chunked layout (and was correct for the
1320 // pre-#3270 layout too whenever a wraparound occurred).
1321 fl::string result;
1322 if (!json_chars.empty()) {
1323 result.reserve(json_chars.size());
1324 for (fl::size i = 0; i < json_chars.size(); ++i) {
1325 result.push_back(json_chars[i]);
1326 }
1327 }
1328
1329 return result;
1330}
fl::size size() const FL_NO_EXCEPT
Definition deque.h:517
bool empty() const FL_NO_EXCEPT
Definition deque.h:516
fl::shared_ptr< json_value > mValue
Definition json.h:263
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References fl::deque< T >::empty(), fl::FL_NO_EXCEPT, mValue, fl::SerializerVisitor::serialize_value(), and fl::deque< T >::size().

Referenced by to_string(), fl::json_value::to_string(), and to_string_native_public().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: