2017-07-09 11:51:38 +02:00
|
|
|
#include <iostream>
|
2018-02-01 22:20:26 +01:00
|
|
|
#include <nlohmann/json.hpp>
|
2015-06-24 15:16:32 +02:00
|
|
|
|
2016-01-30 20:23:14 +01:00
|
|
|
using json = nlohmann::json;
|
2015-06-24 15:16:32 +02:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2015-10-02 15:57:40 +02:00
|
|
|
// create a JSON number
|
2015-06-24 15:16:32 +02:00
|
|
|
json value = 17;
|
|
|
|
|
|
|
|
// explicitly getting pointers
|
2023-06-11 10:06:24 +02:00
|
|
|
auto p1 = value.template get<const json::number_integer_t*>();
|
|
|
|
auto p2 = value.template get<json::number_integer_t*>();
|
|
|
|
auto p3 = value.template get<json::number_integer_t* const>();
|
|
|
|
auto p4 = value.template get<const json::number_integer_t* const>();
|
|
|
|
auto p5 = value.template get<json::number_float_t*>();
|
2015-06-24 15:16:32 +02:00
|
|
|
|
|
|
|
// print the pointees
|
|
|
|
std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
|
|
|
|
std::cout << std::boolalpha << (p5 == nullptr) << '\n';
|
|
|
|
}
|