diff --git a/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_with_names_explicit.cpp b/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_with_names_explicit.cpp index e054f4c13..12a0b8380 100644 --- a/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_with_names_explicit.cpp +++ b/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_with_names_explicit.cpp @@ -13,18 +13,18 @@ struct person int age; }; -void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t) -{ - nlohmann_json_j["json_name"] = nlohmann_json_t.name; - nlohmann_json_j["json_address"] = nlohmann_json_t.address; - nlohmann_json_j["json_age"] = nlohmann_json_t.age; +template ::value, int >= 0> +void to_json(BasicJsonType& nlohmann_json_j, const person& nlohmann_json_t) { + nlohmann_json_j["json_name"] = nlohmann_json_t.name; + nlohmann_json_j["json_address"] = nlohmann_json_t.address; + nlohmann_json_j["json_age"] = nlohmann_json_t.age; } -void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t) -{ - nlohmann_json_t.name = nlohmann_json_j.at("json_name"); - nlohmann_json_t.address = nlohmann_json_j.at("json_address"); - nlohmann_json_t.age = nlohmann_json_j.at("json_age"); +template ::value, int >= 0> +void from_json(const BasicJsonType& nlohmann_json_j, person& nlohmann_json_t) { + nlohmann_json_j.at("json_name").get_to(nlohmann_json_t.name); + nlohmann_json_j.at("json_address").get_to(nlohmann_json_t.address); + nlohmann_json_j.at("json_age").get_to(nlohmann_json_t.age); } } // namespace ns