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

◆ operator[]() [3/4]

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

Definition at line 1992 of file json.h.

1994 {
1995 if (!m_value) {
1997 }
1998 // If we're indexing into a specialized array, convert it to regular JsonArray first
1999 if (m_value->data.is<fl::vector<int16_t>>() ||
2000 m_value->data.is<fl::vector<uint8_t>>() ||
2001 m_value->data.is<fl::vector<float>>()) {
2002 // Convert to regular JsonArray
2003 auto arr = m_value->as_array();
2004 if (arr) {
2006 }
2007 }
2008 // Get the shared_ptr directly from the JsonArray to maintain reference semantics
2009 if (m_value->data.is<JsonArray>()) {
2010 auto arr = m_value->as_array();
2011 if (arr) {
2012 // Ensure the array is large enough
2013 if (idx >= arr->size()) {
2014 for (size_t i = arr->size(); i <= idx; i++) {
2015 arr->push_back(fl::make_shared<JsonValue>(nullptr));
2016 }
2017 }
2018 return Json((*arr)[idx]);
2019 }
2020 }
fl::shared_ptr< JsonValue > m_value
Definition json.h:1622
Json()
Definition json.h:1626
constexpr remove_reference< T >::type && move(T &&t) noexcept
Definition move.h:27
shared_ptr< T > make_shared(Args &&... args)
Definition shared_ptr.h:348
fl::vector< fl::shared_ptr< JsonValue > > JsonArray
Definition json.h:170
HeapVector< T, Allocator > vector
Definition vector.h:1214

References Json(), m_value, fl::make_shared(), and fl::move().

+ Here is the call graph for this function: