Skip to content

[FIX]: Model uses std::string for all types #136

Description

@NikSimDev

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

  • I have searched for existing issues
  • I am using the latest version
  • I have provided a minimal reproduction

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

invalidThis doesn't seem right

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions