From 352b9fd61ea1756fb1e14275d1dbc60cd18d8b13 Mon Sep 17 00:00:00 2001 From: Niels Date: Sat, 11 Apr 2015 19:40:29 +0200 Subject: [PATCH] Updated nlohmann::basicjson::operator T() (markdown) --- nlohmann::basicjson::operator-T().md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/nlohmann::basicjson::operator-T().md b/nlohmann::basicjson::operator-T().md index e8f2e1a..612a195 100644 --- a/nlohmann::basicjson::operator-T().md +++ b/nlohmann::basicjson::operator-T().md @@ -23,6 +23,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}; + std::vector v11 = j1; + std::list v12 = j1; + std::unordered_set v13 = j1; + + nlohmann::json j2 = {{"one", 1}, {"two", 2}, {"three", 3}}; + std::map v21 = j2; + std::multimap v22 = j2; + + nlohmann::json j3 = "Hello, world"; + std::string v31 = j3; +} +``` + ## See also - [**get**](https://github.com/nlohmann/json/wiki/nlohmann::basicjson::get)