mirror of
https://github.com/nlohmann/json.git
synced 2026-05-19 20:55:24 +00:00
deploy: 8a882f32ed
This commit is contained in:
@@ -19,14 +19,16 @@ class person
|
||||
: name(std::move(name_)), address(std::move(address_)), age(age_)
|
||||
{}
|
||||
|
||||
friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
|
||||
template<typename BasicJsonType>
|
||||
friend void to_json(BasicJsonType& nlohmann_json_j, const person& nlohmann_json_t)
|
||||
{
|
||||
nlohmann_json_j["name"] = nlohmann_json_t.name;
|
||||
nlohmann_json_j["address"] = nlohmann_json_t.address;
|
||||
nlohmann_json_j["age"] = nlohmann_json_t.age;
|
||||
}
|
||||
|
||||
friend void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t)
|
||||
template<typename BasicJsonType>
|
||||
friend void from_json(const BasicJsonType& nlohmann_json_j, person& nlohmann_json_t)
|
||||
{
|
||||
nlohmann_json_t.name = nlohmann_json_j.at("name");
|
||||
nlohmann_json_t.address = nlohmann_json_j.at("address");
|
||||
|
||||
@@ -19,7 +19,8 @@ class person
|
||||
: name(std::move(name_)), address(std::move(address_)), age(age_)
|
||||
{}
|
||||
|
||||
friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
|
||||
template<typename BasicJsonType>
|
||||
friend void to_json(BasicJsonType& nlohmann_json_j, const person& nlohmann_json_t)
|
||||
{
|
||||
nlohmann_json_j["name"] = nlohmann_json_t.name;
|
||||
nlohmann_json_j["address"] = nlohmann_json_t.address;
|
||||
|
||||
@@ -19,14 +19,16 @@ class person
|
||||
: name(std::move(name_)), address(std::move(address_)), age(age_)
|
||||
{}
|
||||
|
||||
friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
|
||||
template<typename BasicJsonType>
|
||||
friend void to_json(BasicJsonType& nlohmann_json_j, const person& nlohmann_json_t)
|
||||
{
|
||||
nlohmann_json_j["name"] = nlohmann_json_t.name;
|
||||
nlohmann_json_j["address"] = nlohmann_json_t.address;
|
||||
nlohmann_json_j["age"] = nlohmann_json_t.age;
|
||||
}
|
||||
|
||||
friend void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t)
|
||||
template<typename BasicJsonType>
|
||||
friend void from_json(const BasicJsonType& nlohmann_json_j, person& nlohmann_json_t)
|
||||
{
|
||||
person nlohmann_json_default_obj;
|
||||
nlohmann_json_t.name = nlohmann_json_j.value("name", nlohmann_json_default_obj.name);
|
||||
|
||||
@@ -13,14 +13,16 @@ struct person
|
||||
int age;
|
||||
};
|
||||
|
||||
void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
|
||||
template<typename BasicJsonType>
|
||||
void to_json(BasicJsonType& nlohmann_json_j, const person& nlohmann_json_t)
|
||||
{
|
||||
nlohmann_json_j["name"] = nlohmann_json_t.name;
|
||||
nlohmann_json_j["address"] = nlohmann_json_t.address;
|
||||
nlohmann_json_j["age"] = nlohmann_json_t.age;
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t)
|
||||
template<typename BasicJsonType>
|
||||
void from_json(const BasicJsonType& nlohmann_json_j, person& nlohmann_json_t)
|
||||
{
|
||||
nlohmann_json_t.name = nlohmann_json_j.at("name");
|
||||
nlohmann_json_t.address = nlohmann_json_j.at("address");
|
||||
|
||||
@@ -13,7 +13,8 @@ struct person
|
||||
int age;
|
||||
};
|
||||
|
||||
void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
|
||||
template<typename BasicJsonType>
|
||||
void to_json(BasicJsonType& nlohmann_json_j, const person& nlohmann_json_t)
|
||||
{
|
||||
nlohmann_json_j["name"] = nlohmann_json_t.name;
|
||||
nlohmann_json_j["address"] = nlohmann_json_t.address;
|
||||
|
||||
@@ -18,14 +18,16 @@ struct person
|
||||
{}
|
||||
};
|
||||
|
||||
void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
|
||||
template<typename BasicJsonType>
|
||||
void to_json(BasicJsonType& nlohmann_json_j, const person& nlohmann_json_t)
|
||||
{
|
||||
nlohmann_json_j["name"] = nlohmann_json_t.name;
|
||||
nlohmann_json_j["address"] = nlohmann_json_t.address;
|
||||
nlohmann_json_j["age"] = nlohmann_json_t.age;
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t)
|
||||
template<typename BasicJsonType>
|
||||
void from_json(const BasicJsonType& nlohmann_json_j, person& nlohmann_json_t)
|
||||
{
|
||||
person nlohmann_json_default_obj;
|
||||
nlohmann_json_t.name = nlohmann_json_j.value("name", nlohmann_json_default_obj.name);
|
||||
|
||||
Reference in New Issue
Block a user