Updated nlohmann::basicjson::get (markdown)

Niels committed 2015-04-11 19:38:49 +02:00
1 parent 35e1761b27
commit d33f0e0eea
1 file changed
+27 -1
+27 -1
@@ -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 <json.hpp>
#include <vector>
#include <list>
#include <unordered_set>
#include <map>
#include <string>
int main()
{
nlohmann::json j1 = {1, 2, 3.2, 4.3, 5.4};
auto v11 = j1.get<std::vector<float>>();
auto v12 = j1.get<std::list<int>>();
auto v13 = j1.get<std::unordered_set<float>>();
nlohmann::json j2 = {{"one", 1}, {"two", 2}, {"three", 3}};
auto v21 = j2.get<std::map<std::string, size_t>>();
auto v22 = j2.get<std::multimap<std::string, double>>();
nlohmann::json j3 = "Hello, world";
auto v31 = j3.get<std::string>();
}
```
## 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())