From f2873e6d3a46847126c03ac754dd9993d32a98a5 Mon Sep 17 00:00:00 2001 From: Jared Grubb Date: Sun, 29 Jan 2017 02:46:58 +0000 Subject: [PATCH] README: adjust boost::optional example The "from_json" example for boost::optional is not complete and should also handle the 'none' case. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ee358e5b..6451e2c55 100644 --- a/README.md +++ b/README.md @@ -563,7 +563,9 @@ namespace nlohmann { } static void from_json(const json& j, boost::optional& opt) { - if (!j.is_null()) { + if (j.is_null()) { + opt = boost::none; + } else { opt = j.get(); // same as above, but with // adl_serializer::from_json }