#include #include using json = nlohmann::json; int main() { // create a JSON number json value = 17; // explicitly getting references auto r1 = value.get_ref(); auto r2 = value.get_ref(); // print the values std::cout << r1 << ' ' << r2 << '\n'; // incompatible type throws exception try { auto r3 = value.get_ref(); } catch (json::type_error& ex) { std::cout << ex.what() << '\n'; } }