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

◆ operator[]() [2/4]

json fl::json::operator[] ( const fl::string & key)
inline

Definition at line 589 of file json.h.

591 {
592 if (!mValue || !mValue->is_object()) {
594 }
595 // Get reference to the json_value
596 auto objPtr = mValue->data.ptr<json_object>();
597 if (objPtr) {
598 // If key doesn't exist, create a new json_value and insert it
599 if (objPtr->find(key) == objPtr->end()) {
600 (*objPtr)[key] = fl::make_shared<json_value>(nullptr);
601 }
602 // Return a new json object that wraps the shared_ptr to the json_value
603 return json((*objPtr)[key]);
604 }
605 // Should not happen if mValue is properly initialized as an object
606 //return *reinterpret_cast<json*>(&get_null_value());
json() FL_NOEXCEPT
Definition json.h:134
fl::shared_ptr< json_value > mValue
Definition json.h:130
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
fl::flat_map< fl::string, fl::shared_ptr< json_value >, fl::StringFastLess > json_object
Definition types.h:34