FastLED 3.10.6
Loading...
Searching...
No Matches

◆ json_convert_to_string_core()

FL_NO_INLINE TypeConversionResult fl::detail::json_convert_to_string_core ( const json_value & val,
fl::string * out_value )

Definition at line 177 of file json_dispatch.cpp.hpp.

178 {
180 if (auto* p = val.data.template ptr<fl::string>()) {
181 *out_value = *p;
182 return result;
183 }
184 if (auto* p = val.data.template ptr<i64>()) {
185 *out_value = fl::to_string(*p);
186 result.addWarning(fl::string("int ") + *out_value + " converted to string");
187 return result;
188 }
189 if (auto* p = val.data.template ptr<float>()) {
190#if FL_PLATFORM_HAS_LARGE_MEMORY
191 *out_value = fl::to_string(*p, 6);
192 result.addWarning(fl::string("float ") + *out_value + " converted to string");
193#else
194 (void)p;
195 *out_value = "0";
196 result.setError("float -> string not supported on Low-memory");
197#endif
198 return result;
199 }
200 if (auto* p = val.data.template ptr<bool>()) {
201 *out_value = *p ? "true" : "false";
202 result.addWarning(fl::string("bool converted to string '") + *out_value + "'");
203 return result;
204 }
205 if (val.data.template ptr<fl::nullptr_t>()) {
206 *out_value = "null";
207 result.addWarning("null converted to string 'null'");
208 return result;
209 }
210 result.setError("cannot convert array or object to string");
211 out_value->clear();
212 return result;
213}
void clear(bool freeMemory=false) FL_NO_EXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
string to_string(T value) FL_NO_EXCEPT
Definition string.h:459
variant_t data
Definition types.h:760

References fl::FL_NO_EXCEPT, and fl::to_string().

Referenced by fl::detail::JsonToType< fl::string, void >::convert().

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