]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | #include <iostream> |
2 | #include <nlohmann/json.hpp> | |
3 | ||
4 | using json = nlohmann::json; | |
5 | ||
6 | int main() | |
7 | { | |
8 | // create a JSON number | |
9 | json value = 17; | |
10 | ||
11 | // explicitly getting pointers | |
12 | auto p1 = value.get<const json::number_integer_t*>(); | |
13 | auto p2 = value.get<json::number_integer_t*>(); | |
14 | auto p3 = value.get<json::number_integer_t* const>(); | |
15 | auto p4 = value.get<const json::number_integer_t* const>(); | |
16 | auto p5 = value.get<json::number_float_t*>(); | |
17 | ||
18 | // print the pointees | |
19 | std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n'; | |
20 | std::cout << std::boolalpha << (p5 == nullptr) << '\n'; | |
21 | } |