2017-07-09 11:51:38 +02:00
|
|
|
#include <iostream>
|
2017-04-21 22:07:07 +02:00
|
|
|
#include "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
|
|
|
|
auto p1 = value.get<const json::number_integer_t*>();
|
|
|
|
auto p2 = value.get<json::number_integer_t*>();
|
|
|
|
auto p3 = value.get<json::number_integer_t* const>();
|
|
|
|
auto p4 = value.get<const json::number_integer_t* const>();
|
|
|
|
auto p5 = value.get<json::number_float_t*>();
|
|
|
|
|
|
|
|
// print the pointees
|
|
|
|
std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
|
|
|
|
std::cout << std::boolalpha << (p5 == nullptr) << '\n';
|
|
|
|
}
|