Updated nlohmann::basicjson::operator T() (markdown)
1 parent
d33f0e0eea
commit
352b9fd61e
1 file changed
+26
@@ -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 <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};
|
||||
std::vector<float> v11 = j1;
|
||||
std::list<int> v12 = j1;
|
||||
std::unordered_set<float> v13 = j1;
|
||||
|
||||
nlohmann::json j2 = {{"one", 1}, {"two", 2}, {"three", 3}};
|
||||
std::map<std::string, size_t> v21 = j2;
|
||||
std::multimap<std::string, double> v22 = j2;
|
||||
|
||||
nlohmann::json j3 = "Hello, world";
|
||||
std::string v31 = j3;
|
||||
}
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [**get**](https://github.com/nlohmann/json/wiki/nlohmann::basicjson::get)<br>
|
||||
|
||||
Reference in new issue
Block a user