You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
612 B

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