Set methods for building objects
| 701 | |
| 702 | // Set methods for building objects |
| 703 | void set(const fl::string& key, const json& value) FL_NOEXCEPT { |
| 704 | if (!mValue || !mValue->is_object()) { |
| 705 | mValue = fl::make_shared<json_value>(json_object{}); |
| 706 | } |
| 707 | // Directly assign the value to the object without going through json::operator[] |
| 708 | auto objPtr = mValue->data.ptr<json_object>(); |
| 709 | if (objPtr) { |
| 710 | // Create or update the entry directly |
| 711 | if (value.mValue) { |
| 712 | (*objPtr)[key] = value.mValue; |
| 713 | } else { |
| 714 | // If value has null mValue, create a null json_value |
| 715 | (*objPtr)[key] = fl::make_shared<json_value>(nullptr); |
| 716 | } |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | void set(const fl::string& key, bool value) FL_NOEXCEPT { set(key, json(value)); } |
| 721 | void set(const fl::string& key, int value) FL_NOEXCEPT { set(key, json(value)); } |