From afdee8592152f9a6ab9559e91e71d8c2122875ce Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Mon, 25 Jul 2022 15:24:19 +0200 Subject: [PATCH] Add 'using namespace' to README --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ca1a1808..72d2081de 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,7 @@ json ex1 = json::parse(R"( )"); // Using user-defined (raw) string literals +using namespace nlohmann::literals; json ex2 = R"( { "pi": 3.141, @@ -262,7 +263,12 @@ auto j2 = R"( )"_json; ``` -Note that without appending the `_json` suffix, the passed string literal is not parsed, but just used as JSON string value. That is, `json j = "{ \"happy\": true, \"pi\": 3.141 }"` would just store the string `"{ "happy": true, "pi": 3.141 }"` rather than parsing the actual object. +Note that without appending the `_json` suffix, the passed string literal is not parsed, but just used as JSON string +value. That is, `json j = "{ \"happy\": true, \"pi\": 3.141 }"` would just store the string +`"{ "happy": true, "pi": 3.141 }"` rather than parsing the actual object. + +The string literal should be brought into scope with with `using namespace nlohmann::literals;` +(see [`json::parse()`](https://json.nlohmann.me/api/basic_json/operator_literal_json/)). The above example can also be expressed explicitly using [`json::parse()`](https://json.nlohmann.me/api/basic_json/parse/):