#pragma once namespace config { nlohmann::json read_config(); void write_config(const nlohmann::json& json); template std::optional get(const std::string& key) { const auto cfg = read_config(); if (!cfg.is_object() || !cfg.contains(key)) { return {}; } return {cfg[key].get()}; } template void set(const std::string& key, const T& value) { auto cfg = read_config(); cfg[key] = value; write_config(cfg); } }