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