Version
v0.1.5
Severity
Minor (annoyanse)
Problem Description
// ID, JSON, numbers — all strings
std::map<std::string, std::string> attributes;
Problem:
- Loss of type information
- Slow conversions
- Possible errors (ID "123abc")
Solution: Use nlohmann::json:
template <typename Derived>
class Model {
nlohmann::json attributes; // Typed data
template<typename T>
T getAttribute(const std::string& key) {
return attributes[key].get<T>();
}
};
Verification
Version
v0.1.5
Severity
Minor (annoyanse)
Problem Description
// ID, JSON, numbers — all strings std::map<std::string, std::string> attributes;Problem:
Solution: Use
nlohmann::json:Verification