2017-04-21 20:07:07 +00:00
|
|
|
#include "json.hpp"
|
2015-06-24 13:16:32 +00:00
|
|
|
|
2016-01-30 19:23:14 +00:00
|
|
|
using json = nlohmann::json;
|
2015-06-24 13:16:32 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2015-10-02 13:57:40 +00:00
|
|
|
// create a JSON number
|
2015-06-24 13:16:32 +00: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';
|
|
|
|
}
|