-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Labels
solution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation
Description
Hi, nlohmann!
Thank you for your project.
I don't want to set the key and value manually.
So I have used the code below.
// create a person
ns::person p {"Ned Flanders", "744 Evergreen Terrace", 60};
// conversion: person -> json
json j = p;
std::cout << j << std::endl;
// {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
// conversion: json -> person
auto p2 = j.get<ns::person>();
// that's it
assert(p == p2);
But this code has some errors.
no suitable user-defined conversion from "ns::person" to "nlohmann::json" exists
no instance of overloaded function "nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::get [with ObjectType=std::map, ArrayType=std::vector, StringType=std::string, BooleanType=bool, NumberIntegerType=int64_t, NumberUnsignedType=uint64_t, NumberFloatType=double, AllocatorType=std::allocator, JSONSerializer=nlohmann::adl_serializer]" matches the argument list
How can I fix these errors?
I hope your help.
Thanks.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
solution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation