#pragma once #include #include #include namespace scar { class JsonConfig { public: explicit JsonConfig(const std::string& file_path); // Load config from file (returns false if file doesn't exist) bool load(); // Save config to file bool save() const; // Get value with optional default template T get(const std::string& key, const T& default_value) const { try { if (data_.contains(key)) { return data_[key].get(); } } catch (const std::exception&) { // Fall through to default } return default_value; } // Set value template void set(const std::string& key, const T& value) { data_[key] = value; } // Check if key exists bool has(const std::string& key) const { return data_.contains(key); } // Get file path const std::string& filePath() const { return file_path_; } private: std::string file_path_; nlohmann::json data_; }; } // namespace scar