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

◆ operator[]() [4/4]

const Json fl::Json::operator[] ( size_t idx) const
inline

Definition at line 2022 of file json.h.

2024 {
2025 if (!m_value) {
2026 return Json(nullptr);
2027 }
2028 // Handle regular JsonArray
2029 if (m_value->data.is<JsonArray>()) {
2030 auto arr = m_value->as_array();
2031 if (arr && idx < arr->size()) {
2032 return Json((*arr)[idx]);
2033 }
2034 }
2035 // For specialized arrays, we need to convert them to regular arrays first
2036 // This is needed for compatibility with existing code that expects JsonArray
2037 if (m_value->data.is<fl::vector<int16_t>>() ||
2038 m_value->data.is<fl::vector<uint8_t>>() ||
2039 m_value->data.is<fl::vector<float>>()) {
2040 // Convert to regular JsonArray
2041 auto arr = m_value->as_array();
2042 if (arr && idx < arr->size()) {
2043 return Json((*arr)[idx]);
2044 }
2045 }
fl::shared_ptr< JsonValue > m_value
Definition json.h:1622
Json()
Definition json.h:1626
size_t size() const
Definition json.h:2086
fl::vector< fl::shared_ptr< JsonValue > > JsonArray
Definition json.h:170
HeapVector< T, Allocator > vector
Definition vector.h:1214