]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/doc/examples/get_ref.cpp
2 #include <nlohmann/json.hpp>
4 using json
= nlohmann::json
;
8 // create a JSON number
11 // explicitly getting references
12 auto r1
= value
.get_ref
<const json::number_integer_t
&>();
13 auto r2
= value
.get_ref
<json::number_integer_t
&>();
16 std::cout
<< r1
<< ' ' << r2
<< '\n';
18 // incompatible type throws exception
21 auto r3
= value
.get_ref
<json::number_float_t
&>();
23 catch (json::type_error
& ex
)
25 std::cout
<< ex
.what() << '\n';