diff --git a/README.md b/README.md index 0ead1db6cc..cf102b0732 100644 --- a/README.md +++ b/README.md @@ -345,7 +345,7 @@ Note the difference between serialization and assignment: json j_string = "this is a string"; // retrieve the string value -auto cpp_string = j_string.template get(); +auto cpp_string = j_string.get(); // retrieve the string value (alternative when a variable already exists) std::string cpp_string2; j_string.get_to(cpp_string2); @@ -354,7 +354,7 @@ j_string.get_to(cpp_string2); std::string serialized_string = j_string.dump(); // output of original string -std::cout << cpp_string << " == " << cpp_string2 << " == " << j_string.template get() << '\n'; +std::cout << cpp_string << " == " << cpp_string2 << " == " << j_string.get() << '\n'; // output of serialized value std::cout << j_string << " == " << serialized_string << std::endl; ``` @@ -527,7 +527,7 @@ for (auto& element : j) { } // getter/setter -const auto tmp = j[0].template get(); +const auto tmp = j[0].get(); j[1] = 42; bool foo = j.at(2); @@ -734,7 +734,7 @@ You can switch off implicit conversions by defining `JSON_USE_IMPLICIT_CONVERSIO // strings std::string s1 = "Hello, world!"; json js = s1; -auto s2 = js.template get(); +auto s2 = js.get(); // NOT RECOMMENDED std::string s3 = js; std::string s4; @@ -743,7 +743,7 @@ s4 = js; // Booleans bool b1 = true; json jb = b1; -auto b2 = jb.template get(); +auto b2 = jb.get(); // NOT RECOMMENDED bool b3 = jb; bool b4; @@ -752,7 +752,7 @@ b4 = jb; // numbers int i = 42; json jn = i; -auto f = jn.template get(); +auto f = jn.get(); // NOT RECOMMENDED double f2 = jb; double f3; @@ -795,9 +795,9 @@ j["age"] = p.age; // convert from JSON: copy each value from the JSON object ns::person p { - j["name"].template get(), - j["address"].template get(), - j["age"].template get() + j["name"].get(), + j["address"].get(), + j["age"].get() }; ``` @@ -814,7 +814,7 @@ std::cout << j << std::endl; // {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} // conversion: json -> person -auto p2 = j.template get(); +auto p2 = j.get(); // that's it assert(p == p2); @@ -841,13 +841,13 @@ namespace ns { ``` That's all! When calling the `json` constructor with your type, your custom `to_json` method will be automatically called. -Likewise, when calling `template get()` or `get_to(your_type&)`, the `from_json` method will be called. +Likewise, when calling `get()` or `get_to(your_type&)`, the `from_json` method will be called. Some important things: - Those methods **MUST** be in your type's namespace (which can be the global namespace), or the library will not be able to locate them (in this example, they are in namespace `ns`, where `person` is defined). - Those methods **MUST** be available (e.g., proper headers must be included) everywhere you use these conversions. Look at [issue 1108](https://github.com/nlohmann/json/issues/1108) for errors that may occur otherwise. -- When using `template get()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.) +- When using `get()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.) - In function `from_json`, use function [`at()`](https://json.nlohmann.me/api/basic_json/at/) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior. - You do not need to add serializers or deserializers for STL types like `std::vector`: the library already implements these. @@ -927,8 +927,8 @@ namespace nlohmann { if (j.is_null()) { opt = boost::none; } else { - opt = j.template get(); // same as above, but with - // adl_serializer::from_json + opt = j.get(); // same as above, but with + // adl_serializer::from_json } } }; @@ -955,7 +955,7 @@ namespace nlohmann { // note: the return type is no longer 'void', and the method only takes // one argument static move_only_type from_json(const json& j) { - return {j.template get()}; + return {j.get()}; } // Here's the catch! You must provide a to_json method! Otherwise, you @@ -1019,7 +1019,7 @@ struct bad_serializer static void to_json(const BasicJsonType& j, T& value) { // this calls BasicJsonType::json_serializer::from_json(j, value) // if BasicJsonType::json_serializer == bad_serializer ... oops! - value = j.template get(); // oops! + value = j.get(); // oops! } }; ``` @@ -1059,11 +1059,11 @@ assert(j == "stopped"); // json string to enum json j3 = "running"; -assert(j3.template get() == TS_RUNNING); +assert(j3.get() == TS_RUNNING); // undefined json value to enum (where the first map entry above is the default) json jPi = 3.14; -assert(jPi.template get() == TS_INVALID); +assert(jPi.get() == TS_INVALID); ``` Just as in [Arbitrary Type Conversions](#arbitrary-types-conversions) above, @@ -1073,7 +1073,7 @@ Just as in [Arbitrary Type Conversions](#arbitrary-types-conversions) above, Other Important points: -- When using `template get()`, undefined JSON values will default to the first pair specified in your map. Select this default pair carefully. +- When using `get()`, undefined JSON values will default to the first pair specified in your map. Select this default pair carefully. - If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the map will be returned when converting to or from JSON. ### Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData) diff --git a/docs/mkdocs/docs/api/adl_serializer/from_json.md b/docs/mkdocs/docs/api/adl_serializer/from_json.md index 176290e24e..2f49e4b802 100644 --- a/docs/mkdocs/docs/api/adl_serializer/from_json.md +++ b/docs/mkdocs/docs/api/adl_serializer/from_json.md @@ -37,7 +37,7 @@ Copy of the JSON value, converted to `ValueType` ??? example "Example: (1) Default-constructible type" The example below shows how a `from_json` function can be implemented for a user-defined type. This function is - called by the `adl_serializer` when `template get()` is called. + called by the `adl_serializer` when `get()` is called. ```cpp --8<-- "examples/from_json__default_constructible.cpp" diff --git a/docs/mkdocs/docs/api/macros/json_disable_enum_serialization.md b/docs/mkdocs/docs/api/macros/json_disable_enum_serialization.md index 6acfdc2a1c..e1418943d1 100644 --- a/docs/mkdocs/docs/api/macros/json_disable_enum_serialization.md +++ b/docs/mkdocs/docs/api/macros/json_disable_enum_serialization.md @@ -53,7 +53,7 @@ The default value is `0`. const json j = Choice::first; // normally invokes from_json parse function but with JSON_DISABLE_ENUM_SERIALIZATION defined, it does not - Choice ch = j.template get(); + Choice ch = j.get(); } ``` @@ -86,7 +86,7 @@ The default value is `0`. const json j = Choice::first; // uses user-defined from_json function defined by macro - Choice ch = j.template get(); + Choice ch = j.get(); } ``` @@ -109,7 +109,7 @@ The default value is `0`. void from_json(const json& j, Choice& ch) { - auto value = j.template get(); + auto value = j.get(); if (value == "first") { ch = Choice::first; @@ -122,7 +122,7 @@ The default value is `0`. void to_json(json& j, const Choice& ch) { - auto value = j.template get(); + auto value = j.get(); if (value == "first") { ch = Choice::first; @@ -139,7 +139,7 @@ The default value is `0`. const json j = Choice::first; // uses user-defined from_json function - Choice ch = j.template get(); + Choice ch = j.get(); } ``` diff --git a/docs/mkdocs/docs/api/macros/json_use_implicit_conversions.md b/docs/mkdocs/docs/api/macros/json_use_implicit_conversions.md index 0a5ad4df46..22f6d00725 100644 --- a/docs/mkdocs/docs/api/macros/json_use_implicit_conversions.md +++ b/docs/mkdocs/docs/api/macros/json_use_implicit_conversions.md @@ -46,7 +46,7 @@ By default, implicit conversions are enabled. ```cpp json j = "Hello, world!"; - auto s = j.template get(); + auto s = j.get(); ``` ## See also diff --git a/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md b/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md index adaceae8db..fba6b217ab 100644 --- a/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md +++ b/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md @@ -37,7 +37,7 @@ inline void from_json(const BasicJsonType& j, type& e); !!! important "Important notes" - - When using [`template get()`](../basic_json/get.md), undefined JSON values will default to the first specified + - When using [`get()`](../basic_json/get.md), undefined JSON values will default to the first specified conversion. Select this default pair carefully. See example 1 below. - If an enum or JSON value is specified in multiple conversions, the first matching conversion from the top of the list will be returned when converting to or from JSON. See example 2 below. diff --git a/docs/mkdocs/docs/examples/from_json__default_constructible.cpp b/docs/mkdocs/docs/examples/from_json__default_constructible.cpp index 07d71ac951..17c0551c8c 100644 --- a/docs/mkdocs/docs/examples/from_json__default_constructible.cpp +++ b/docs/mkdocs/docs/examples/from_json__default_constructible.cpp @@ -31,7 +31,7 @@ int main() j["address"] = "744 Evergreen Terrace"; j["age"] = 60; - auto p = j.template get(); + auto p = j.get(); std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl; } diff --git a/docs/mkdocs/docs/examples/from_json__non_default_constructible.cpp b/docs/mkdocs/docs/examples/from_json__non_default_constructible.cpp index ec8206eade..6cb86153cc 100644 --- a/docs/mkdocs/docs/examples/from_json__non_default_constructible.cpp +++ b/docs/mkdocs/docs/examples/from_json__non_default_constructible.cpp @@ -47,7 +47,7 @@ int main() j["address"] = "744 Evergreen Terrace"; j["age"] = 60; - auto p = j.template get(); + auto p = j.get(); std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl; } diff --git a/docs/mkdocs/docs/examples/get__PointerType.cpp b/docs/mkdocs/docs/examples/get__PointerType.cpp index 309c8deebb..2f32ed7af6 100644 --- a/docs/mkdocs/docs/examples/get__PointerType.cpp +++ b/docs/mkdocs/docs/examples/get__PointerType.cpp @@ -9,11 +9,11 @@ int main() json value = 17; // explicitly getting pointers - auto p1 = value.template get(); - auto p2 = value.template get(); - auto p3 = value.template get(); - auto p4 = value.template get(); - auto p5 = value.template get(); + auto p1 = value.get(); + auto p2 = value.get(); + auto p3 = value.get(); + auto p4 = value.get(); + auto p5 = value.get(); // print the pointees std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n'; diff --git a/docs/mkdocs/docs/examples/get__ValueType_const.cpp b/docs/mkdocs/docs/examples/get__ValueType_const.cpp index db63791fcb..7a703aaeb1 100644 --- a/docs/mkdocs/docs/examples/get__ValueType_const.cpp +++ b/docs/mkdocs/docs/examples/get__ValueType_const.cpp @@ -22,14 +22,14 @@ int main() }; // use explicit conversions - auto v1 = json_types["boolean"].template get(); - auto v2 = json_types["number"]["integer"].template get(); - auto v3 = json_types["number"]["integer"].template get(); - auto v4 = json_types["number"]["floating-point"].template get(); - auto v5 = json_types["number"]["floating-point"].template get(); - auto v6 = json_types["string"].template get(); - auto v7 = json_types["array"].template get>(); - auto v8 = json_types.template get>(); + auto v1 = json_types["boolean"].get(); + auto v2 = json_types["number"]["integer"].get(); + auto v3 = json_types["number"]["integer"].get(); + auto v4 = json_types["number"]["floating-point"].get(); + auto v5 = json_types["number"]["floating-point"].get(); + auto v6 = json_types["string"].get(); + auto v7 = json_types["array"].get>(); + auto v8 = json_types.get>(); // print the conversion results std::cout << v1 << '\n'; diff --git a/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_explicit.cpp b/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_explicit.cpp index e2021e235d..ce13ff114f 100644 --- a/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_explicit.cpp +++ b/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_explicit.cpp @@ -47,13 +47,13 @@ int main() // deserialization: json -> person json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); + auto p2 = j2.get(); // incomplete deserialization: json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; try { - auto p3 = j3.template get(); + auto p3 = j3.get(); } catch (const json::exception& e) { diff --git a/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_macro.cpp b/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_macro.cpp index 4ecd4294fc..ab8657801b 100644 --- a/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_macro.cpp +++ b/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_macro.cpp @@ -33,13 +33,13 @@ int main() // deserialization: json -> person json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); + auto p2 = j2.get(); // incomplete deserialization: json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; try { - auto p3 = j3.template get(); + auto p3 = j3.get(); } catch (const json::exception& e) { diff --git a/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.cpp b/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.cpp index 3977955766..2713444b62 100644 --- a/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.cpp +++ b/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.cpp @@ -48,10 +48,10 @@ int main() // deserialization: json -> person json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); + auto p2 = j2.get(); // incomplete deserialization: json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; - auto p3 = j3.template get(); + auto p3 = j3.get(); std::cout << "roundtrip: " << json(p3) << std::endl; } diff --git a/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_with_default_macro.cpp b/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_with_default_macro.cpp index 52668516b5..851a3582f4 100644 --- a/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_with_default_macro.cpp +++ b/docs/mkdocs/docs/examples/nlohmann_define_type_intrusive_with_default_macro.cpp @@ -33,10 +33,10 @@ int main() // deserialization: json -> person json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); + auto p2 = j2.get(); // incomplete deserialization: json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; - auto p3 = j3.template get(); + auto p3 = j3.get(); std::cout << "roundtrip: " << json(p3) << std::endl; } diff --git a/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp b/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp index 9f5cdc173e..dfbdde4ac2 100644 --- a/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp +++ b/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp @@ -40,13 +40,13 @@ int main() // deserialization: json -> person json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); + auto p2 = j2.get(); // incomplete deserialization: json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; try { - auto p3 = j3.template get(); + auto p3 = j3.get(); } catch (const json::exception& e) { diff --git a/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp b/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp index d11691b701..cdf90dc2c0 100644 --- a/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp +++ b/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp @@ -26,13 +26,13 @@ int main() // deserialization: json -> person json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); + auto p2 = j2.get(); // incomplete deserialization: json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; try { - auto p3 = j3.template get(); + auto p3 = j3.get(); } catch (const json::exception& e) { diff --git a/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp b/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp index 1bdd25ed90..23384b70cf 100644 --- a/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp +++ b/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp @@ -46,10 +46,10 @@ int main() // deserialization: json -> person json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); + auto p2 = j2.get(); // incomplete deserialization: json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; - auto p3 = j3.template get(); + auto p3 = j3.get(); std::cout << "roundtrip: " << json(p3) << std::endl; } diff --git a/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp b/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp index 8c41c65ecd..aa9bc53b4b 100644 --- a/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp +++ b/docs/mkdocs/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp @@ -31,10 +31,10 @@ int main() // deserialization: json -> person json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); + auto p2 = j2.get(); // incomplete deserialization: json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; - auto p3 = j3.template get(); + auto p3 = j3.get(); std::cout << "roundtrip: " << json(p3) << std::endl; } diff --git a/docs/mkdocs/docs/examples/nlohmann_json_serialize_enum.cpp b/docs/mkdocs/docs/examples/nlohmann_json_serialize_enum.cpp index a40db49eaa..f9e472c64b 100644 --- a/docs/mkdocs/docs/examples/nlohmann_json_serialize_enum.cpp +++ b/docs/mkdocs/docs/examples/nlohmann_json_serialize_enum.cpp @@ -44,16 +44,16 @@ int main() // deserialization json j_running = "running"; json j_blue = "blue"; - auto running = j_running.template get(); - auto blue = j_blue.template get(); + auto running = j_running.get(); + auto blue = j_blue.get(); std::cout << j_running << " -> " << running << ", " << j_blue << " -> " << static_cast(blue) << std::endl; // deserializing undefined JSON value to enum // (where the first map entry above is the default) json j_pi = 3.14; - auto invalid = j_pi.template get(); - auto unknown = j_pi.template get(); + auto invalid = j_pi.get(); + auto unknown = j_pi.get(); std::cout << j_pi << " -> " << invalid << ", " << j_pi << " -> " << static_cast(unknown) << std::endl; } diff --git a/docs/mkdocs/docs/examples/nlohmann_json_serialize_enum_2.cpp b/docs/mkdocs/docs/examples/nlohmann_json_serialize_enum_2.cpp index b35e94cc56..fd27226ca9 100644 --- a/docs/mkdocs/docs/examples/nlohmann_json_serialize_enum_2.cpp +++ b/docs/mkdocs/docs/examples/nlohmann_json_serialize_enum_2.cpp @@ -26,8 +26,8 @@ int main() // deserialization json j_rot = "rot"; - auto rot = j_rot.template get(); - auto red = j_red.template get(); + auto rot = j_rot.get(); + auto red = j_red.get(); std::cout << j_rot << " -> " << static_cast(rot) << std::endl; std::cout << j_red << " -> " << static_cast(red) << std::endl; } diff --git a/docs/mkdocs/docs/features/arbitrary_types.md b/docs/mkdocs/docs/features/arbitrary_types.md index c0fa4515c4..1e79bfec28 100644 --- a/docs/mkdocs/docs/features/arbitrary_types.md +++ b/docs/mkdocs/docs/features/arbitrary_types.md @@ -24,9 +24,9 @@ j["age"] = p.age; // convert from JSON: copy each value from the JSON object ns::person p { - j["name"].template get(), - j["address"].template get(), - j["age"].template get() + j["name"].get(), + j["address"].get(), + j["age"].get() }; ``` @@ -43,7 +43,7 @@ std::cout << j << std::endl; // {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} // conversion: json -> person -auto p2 = j.template get(); +auto p2 = j.get(); // that's it assert(p == p2); @@ -70,13 +70,13 @@ namespace ns { ``` That's all! When calling the `json` constructor with your type, your custom `to_json` method will be automatically called. -Likewise, when calling `template get()` or `get_to(your_type&)`, the `from_json` method will be called. +Likewise, when calling `get()` or `get_to(your_type&)`, the `from_json` method will be called. Some important things: * Those methods **MUST** be in your type's namespace (which can be the global namespace), or the library will not be able to locate them (in this example, they are in namespace `ns`, where `person` is defined). * Those methods **MUST** be available (e.g., proper headers must be included) everywhere you use these conversions. Look at [#1108](https://github.com/nlohmann/json/issues/1108) for errors that may occur otherwise. -* When using `template get()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.) +* When using `get()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.) * In function `from_json`, use function [`at()`](../api/basic_json/at.md) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior. * You do not need to add serializers or deserializers for STL types like `std::vector`: the library already implements these. @@ -191,7 +191,7 @@ struct adl_serializer> { if (j.is_null()) { opt = boost::none; } else { - opt = j.template get(); // same as above, but with + opt = j.get(); // same as above, but with // adl_serializer::from_json } } @@ -224,7 +224,7 @@ namespace nlohmann { // note: the return type is no longer 'void', and the method only takes // one argument static move_only_type from_json(const json& j) { - return {j.template get()}; + return {j.get()}; } // Here's the catch! You must provide a to_json method! Otherwise, you @@ -288,7 +288,7 @@ struct bad_serializer static void from_json(const BasicJsonType& j, T& value) { // this calls BasicJsonType::json_serializer::from_json(j, value); // if BasicJsonType::json_serializer == bad_serializer ... oops! - value = j.template template get(); // oops! + value = j.template get(); // oops! } }; ``` diff --git a/docs/mkdocs/docs/features/enum_conversion.md b/docs/mkdocs/docs/features/enum_conversion.md index 58d353a0c4..bd3977d919 100644 --- a/docs/mkdocs/docs/features/enum_conversion.md +++ b/docs/mkdocs/docs/features/enum_conversion.md @@ -36,11 +36,11 @@ assert(j == "stopped"); // json string to enum json j3 = "running"; -assert(j3.template get() == TS_RUNNING); +assert(j3.get() == TS_RUNNING); // undefined json value to enum (where the first map entry above is the default) json jPi = 3.14; -assert(jPi.template get() == TS_INVALID ); +assert(jPi.get() == TS_INVALID ); ``` ## Notes @@ -54,7 +54,7 @@ Just as in [Arbitrary Type Conversions](arbitrary_types.md) above, Other Important points: -- When using `template get()`, undefined JSON values will default to the first pair specified in your map. Select this +- When using `get()`, undefined JSON values will default to the first pair specified in your map. Select this default pair carefully. - If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the map will be returned when converting to or from JSON. diff --git a/docs/mkdocs/docs/features/types/number_handling.md b/docs/mkdocs/docs/features/types/number_handling.md index 87680ba068..9102376bb9 100644 --- a/docs/mkdocs/docs/features/types/number_handling.md +++ b/docs/mkdocs/docs/features/types/number_handling.md @@ -235,9 +235,9 @@ integers, and between integers and floating-point values to integers. This behav !!! warning "Unconditional number conversions" ```cpp hl_lines="3" - double d = 42.3; // non-integer double value 42.3 - json jd = d; // stores double value 42.3 - std::int64_t i = jd.template get(); // now i==42; no warning or error is produced + double d = 42.3; // non-integer double value 42.3 + json jd = d; // stores double value 42.3 + std::int64_t i = jd.get(); // now i==42; no warning or error is produced ``` Note the last line with throw a [`json.exception.type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) @@ -259,7 +259,7 @@ The rationale is twofold: if (jd.is_number_integer()) { // if so, do the conversion and use i - std::int64_t i = jd.template get(); + std::int64_t i = jd.get(); // ... } else diff --git a/docs/mkdocs/docs/integration/migration_guide.md b/docs/mkdocs/docs/integration/migration_guide.md index 423b746d2b..e81b8c08fb 100644 --- a/docs/mkdocs/docs/integration/migration_guide.md +++ b/docs/mkdocs/docs/integration/migration_guide.md @@ -187,7 +187,7 @@ conversions with calls to [`get`](../api/basic_json/get.md), [`get_to`](../api/b ```cpp nlohmann::json j = "Hello, world!"; - auto s = j.template get(); + auto s = j.get(); ``` === "Future-proof (alternative)"