Skip to content

From Version 2.1.1 to 3.6.1 serialize std::set #1676

Description

@MattiasEppler

I upgraded to version 3.6.1 until this I serialized a std::set in this way


class Settings
{
  std::set<MetaData> Clients{};
}

inline void to_json(json& j, const Settings& settings)
{
        j = json
        {
            { "clients", settings.Clients },
        };
}

inline void from_json(const json& j, Settings& settings)
{
        auto clients = j.at("clients").get<vector<MetaData>>();

        for (const auto& client : clients)
        {
            settings.Clients.insert(client);
        }
}

Now I get the errors:

Error C2440: 'initializing': cannot convert from 'initializer list' to 'nlohmann::json' (142)
Error C2672: 'nlohmann::basic_jsonstd::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer::get': no matching overloaded function found (160)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions