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

◆ operator[]() [3/4]

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

Definition at line 729 of file json.h.

731 {
732 if (!mValue) {
733 return json(nullptr);
734 }
735 // Handle regular json_array - zero-copy pointer access
736 auto arrPtr = mValue->as_array();
737 if (arrPtr) {
738 if (idx < arrPtr->size()) {
739 return json((*arrPtr)[idx]);
740 }
741 return json(nullptr);
742 }
743 // For packed arrays, extract element directly without converting the whole array
744 if (auto p = mValue->data.ptr<fl::vector<i16>>()) {
745 if (idx < p->size()) return json(static_cast<i64>((*p)[idx]));
746 } else if (auto p = mValue->data.ptr<fl::vector<u8>>()) {
747 if (idx < p->size()) return json(static_cast<i64>((*p)[idx]));
748 } else if (auto p = mValue->data.ptr<fl::vector<float>>()) {
749 if (idx < p->size()) return json((*p)[idx]);
750 }
size_t size() const FL_NO_EXCEPT
Definition json.h:798
fl::shared_ptr< json_value > mValue
Definition json.h:263
json() FL_NO_EXCEPT
Definition json.h:267
fl::i64 i64
Definition stdint.h:221