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

◆ operator[]() [1/4]

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

Definition at line 2047 of file json.h.

2049 {
2050 if (!m_value || !m_value->is_object()) {
2052 }
2053 // Get reference to the JsonValue
2054 auto objPtr = m_value->data.ptr<JsonObject>();
2055 if (objPtr) {
2056 // If key doesn't exist, create a new JsonValue and insert it
2057 if (objPtr->find(key) == objPtr->end()) {
2058 (*objPtr)[key] = fl::make_shared<JsonValue>(nullptr);
2059 }
2060 // Return a new Json object that wraps the shared_ptr to the JsonValue
2061 return Json((*objPtr)[key]);
2062 }
2063 // Should not happen if m_value is properly initialized as an object
2064 //return *reinterpret_cast<Json*>(&get_null_value());
fl::shared_ptr< JsonValue > m_value
Definition json.h:1622
Json()
Definition json.h:1626
shared_ptr< T > make_shared(Args &&... args)
Definition shared_ptr.h:348
fl::HashMap< fl::string, fl::shared_ptr< JsonValue > > JsonObject
Definition json.h:171