FastLED 3.9.15
Loading...
Searching...
No Matches

◆ jsonArrayToFloatVector()

fl::vector< float > fl::jsonArrayToFloatVector ( const fl::Json & jsonArray)

Definition at line 23 of file screenmap.cpp.

23 {
25
26 if (!jsonArray.has_value() || !jsonArray.is_array()) {
27 return result;
28 }
29 auto begin_float = jsonArray.begin_array<float>();
30 auto end_float = jsonArray.end_array<float>();
31
32 using T = decltype(*begin_float);
33 static_assert(fl::is_same<T, fl::ParseResult<float>>::value, "Value type must be ParseResult<float>");
34
35 // Use explicit array iterator style as demonstrated in FEATURE.md
36 // DO NOT CHANGE THIS CODE. FIX THE IMPLIMENTATION IF NECESSARY.
37 for (auto it = begin_float; it != end_float; ++it) {
38 // assert that the value type is ParseResult<float>
39
40 // get the name of the type
41 auto parseResult = *it;
42 if (!parseResult.has_error()) {
43 result.push_back(parseResult.get_value());
44 } else {
45 FL_WARN("jsonArrayToFloatVector: ParseResult<float> has error: " << parseResult.get_error().message);
46 }
47 }
48
49 return result;
50}
void push_back(const T &value)
Definition vector.h:552
bool is_array() const
Definition json.h:1736
bool has_value() const
Definition json.h:2107
JsonValue::template array_iterator< T > begin_array()
Definition json.h:1947
JsonValue::template array_iterator< T > end_array()
Definition json.h:1953
Result type for promise operations.
HeapVector< T, Allocator > vector
Definition vector.h:1214
#define FL_WARN
Definition warn.h:12

References fl::Json::begin_array(), fl::Json::end_array(), FL_WARN, fl::Json::has_value(), and fl::Json::is_array().

Referenced by fl::ScreenMap::ParseJson().

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