static void throwaway2() {
// a simple struct to model a person
struct person {
std::string name;
std::string address;
int age;
};
// create a person
person p{"Ned Flanders", "744 Evergreen Terrace", 60};
// conversion: person -> json
auto j = R"({
"name": "Ned Flanders",
"address": "744 Evergreen Terrace",
"age": 60
})"_json;
std::cout << j << std::endl;
auto p2 = j.get<person>(); // Error here
assert(p == p2);
}
error C2672: 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>>::get': no matching overloaded function found
error C2783: 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>> nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>>::get(void) const': could not deduce template argument for '__formal'
[build] D:\Libs\vcpkg\installed\x64-windows\include\nlohmann/json.hpp(2848): message : see declaration of 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>>::get'
Can you provide a small but working code example?
Code:
Error:
Which version of the library did you use?
developbranch