#pragma once #include // thirdparty #include "nlohmann/json.hpp" // project #include "GeneralUtils.h" namespace nsKeyValue { using stKeyValue = struct _stKeyValue { std::string Name; double Value{ 0.0 }; }; using stKeyValueBool = struct _stKeyValueBool { std::string Name; bool Value{}; }; }; namespace nsKeyValue { using namespace nlohmann; using namespace nsUtils; void from_json(const json& j, stKeyValue& x); void to_json(json& j, const stKeyValue& x); void from_json(const json& j, stKeyValueBool& x); void to_json(json& j, const stKeyValueBool& x); inline void from_json(const json& j, stKeyValue& x) { getValue(j, "Name", x.Name); getValue(j, "Value", x.Value); } inline void to_json(json& j, const stKeyValue& x) { j = nlohmann::json{ { "Name", x.Name }, { "Value", x.Value } }; } inline void from_json(const json& j, stKeyValueBool& x) { getValue(j, "Name", x.Name); getValue(j, "Value", x.Value); } inline void to_json(json& j, const stKeyValueBool& x) { j = nlohmann::json{ { "Name", x.Name }, { "Value", x.Value } }; } }