FastLED 3.10.9
Loading...
Searching...
No Matches

◆ set() [4/11]

void fl::json::set ( const fl::string & key,
const json & value )
inline

Definition at line 873 of file json.h.

875 {
876 if (!mValue || !mValue->is_object()) {
878 }
879 // FastLED#3588: make_shared degrades to an empty shared_ptr under
880 // OOM, so mValue can be null here — dereferencing it would read
881 // through null. Degrade gracefully (the set becomes a no-op).
882 if (!mValue) {
883 return;
884 }
885 // Directly assign the value to the object without going through json::operator[]
886 auto objPtr = mValue->data.ptr<json_object>();
887 if (objPtr) {
888 // Create or update the entry directly
889 if (value.mValue) {
890 (*objPtr)[key] = value.mValue;
891 } else {
892 // If value has null mValue, create a null json_value
893 (*objPtr)[key] = fl::make_shared<json_value>(nullptr);
894 }
fl::shared_ptr< json_value > mValue
Definition json.h:263
T value() const FL_NO_EXCEPT
Definition json.h:497
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
Definition shared_ptr.h:423
fl::flat_map< fl::string, fl::shared_ptr< json_value >, fl::StringFastLess > json_object
Definition types.h:55

References json(), fl::FL_NO_EXCEPT, fl::adl_barrier::make_shared(), mValue, and value().

Referenced by autoresearch::flex_io::buildDeviceInfo(), fl::crgbToJson(), fl::deviceJson(), fl::WLED::getPlaylistConfig(), fl::WLED::getState(), fl::Rpc::handle(), fl::detail::makeJsonRpcError(), fl::Remote::processRpc(), fl::Remote::reportError(), fl::Remote::reportError(), fl::net::http::HttpStreamTransport::rpc(), fl::net::http::HttpStreamTransport::rpcStream(), fl::Rpc::schema(), fl::ResponseSend::sendFinal(), fl::net::http::HttpStreamTransport::sendHeartbeat(), set(), setup(), fl::RpcResult::to_json(), and fl::ScreenMap::toJson().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: