From d33f0e0eeaeb5392b43da5cb51494e6b8b93b3c4 Mon Sep 17 00:00:00 2001 From: Niels Date: Sat, 11 Apr 2015 19:38:49 +0200 Subject: [PATCH] Updated nlohmann::basicjson::get (markdown) --- nlohmann::basicjson::get.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/nlohmann::basicjson::get.md b/nlohmann::basicjson::get.md index 043aba7..bd66ba3 100644 --- a/nlohmann::basicjson::get.md +++ b/nlohmann::basicjson::get.md @@ -34,6 +34,32 @@ Amortized linear in the size of the JSON type. `std::std::logic_error` if types are not compatible. +## Example + +```cpp +#include +#include +#include +#include +#include +#include + +int main() +{ + nlohmann::json j1 = {1, 2, 3.2, 4.3, 5.4}; + auto v11 = j1.get>(); + auto v12 = j1.get>(); + auto v13 = j1.get>(); + + nlohmann::json j2 = {{"one", 1}, {"two", 2}, {"three", 3}}; + auto v21 = j2.get>(); + auto v22 = j2.get>(); + + nlohmann::json j3 = "Hello, world"; + auto v31 = j3.get(); +} +``` + ## See also -- [**(implicit value conversion)**](https://github.com/nlohmann/json/wiki/nlohmann::basicjson::operator-T()) +- [**(implicit value conversion)**](https://github.com/nlohmann/json/wiki/nlohmann::basicjson::operator-T()) \ No newline at end of file