-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Labels
kind: enhancement/improvementrelease item: ⚡ improvementsolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation
Milestone
Description
Currently, the API for registering custom types is as follows:
using nlohmann::json;
namespace ns {
void to_json(json& j, const person& p) {
j = json{{"name", p.name}, {"address", p.address}, {"age", p.age}};
}
void from_json(const json& j, person& p) {
j.at("name").get_to(p.name);
j.at("address").get_to(p.address);
j.at("age").get_to(p.age);
}
It would be great if there was a MACRO-style registration a bit like what msgpack-c uses:
struct person
{
std::string name;
std::string address;
int age;
MSGPACK_DEFINE_MAP(name, address, age);
};
or yas:
struct person
{
std::string name;
std::string address;
int age;
YAS_DEFINE_STRUCT_SERIALIZE("person", name, address, age);
};
or
struct person
{
std::string name;
std::string address;
int age;
};
YAS_DEFINE_INTRUSIVE_SERIALIZE("person", name, address, age);
gocarlos
Metadata
Metadata
Assignees
Labels
kind: enhancement/improvementrelease item: ⚡ improvementsolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation