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

◆ operator[]() [3/4]

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

Definition at line 566 of file json.h.

568 {
569 if (!mValue) {
570 return json(nullptr);
571 }
572 // Handle regular json_array - zero-copy pointer access
573 auto arrPtr = mValue->as_array();
574 if (arrPtr) {
575 if (idx < arrPtr->size()) {
576 return json((*arrPtr)[idx]);
577 }
578 return json(nullptr);
579 }
580 // For packed arrays, extract element directly without converting the whole array
581 if (auto p = mValue->data.ptr<fl::vector<i16>>()) {
582 if (idx < p->size()) return json(static_cast<i64>((*p)[idx]));
583 } else if (auto p = mValue->data.ptr<fl::vector<u8>>()) {
584 if (idx < p->size()) return json(static_cast<i64>((*p)[idx]));
585 } else if (auto p = mValue->data.ptr<fl::vector<float>>()) {
586 if (idx < p->size()) return json((*p)[idx]);
587 }
json() FL_NOEXCEPT
Definition json.h:134
fl::shared_ptr< json_value > mValue
Definition json.h:130
size_t size() const FL_NOEXCEPT
Definition json.h:633
fl::i64 i64
Definition s16x16x4.h:222