diff --git a/api/macros/nlohmann_define_type_intrusive/index.html b/api/macros/nlohmann_define_type_intrusive/index.html index a1d28eecc..c9a52538f 100644 --- a/api/macros/nlohmann_define_type_intrusive/index.html +++ b/api/macros/nlohmann_define_type_intrusive/index.html @@ -22,9 +22,9 @@ person(std::string name_, std::string address_, int age_) : name(std::move(name_)), address(std::move(address_)), age(age_) {} - - NLOHMANN_DEFINE_TYPE_INTRUSIVE(person, name, address, age) -}; + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(person, name, address, age) +}; } // namespace ns int main() @@ -72,8 +72,8 @@ person(std::string name_, std::string address_, int age_) : name(std::move(name_)), address(std::move(address_)), age(age_) {} - - friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t) + + friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t) { nlohmann_json_j["name"] = nlohmann_json_t.name; nlohmann_json_j["address"] = nlohmann_json_t.address; @@ -85,8 +85,8 @@ nlohmann_json_t.name = nlohmann_json_j.at("name"); nlohmann_json_t.address = nlohmann_json_j.at("address"); nlohmann_json_t.age = nlohmann_json_j.at("age"); - } -}; + } +}; } // namespace ns int main() @@ -132,9 +132,9 @@ person(std::string name_, std::string address_, int age_) : name(std::move(name_)), address(std::move(address_)), age(age_) {} - - NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(person, name, address, age) -}; + + NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(person, name, address, age) +}; } // namespace ns int main() @@ -190,8 +190,8 @@ nlohmann_json_t.name = nlohmann_json_j.value("name", nlohmann_json_default_obj.name); nlohmann_json_t.address = nlohmann_json_j.value("address", nlohmann_json_default_obj.address); nlohmann_json_t.age = nlohmann_json_j.value("age", nlohmann_json_default_obj.age); - } -}; + } +}; } // namespace ns int main() @@ -211,4 +211,4 @@ auto p3 = j3.template get<ns::person>(); std::cout << "roundtrip: " << json(p3) << std::endl; } -
Note how a default-initialized person
object is used in the from_json
to fill missing values.