at__object_t_key_type_const.cpp
Go to the documentation of this file.
00001 #include <json.hpp>
00002 
00003 using json = nlohmann::json;
00004 
00005 int main()
00006 {
00007     // create JSON object
00008     json object =
00009     {
00010         {"the good", "il buono"},
00011         {"the bad", "il cativo"},
00012         {"the ugly", "il brutto"}
00013     };
00014 
00015     // output element with key "the ugly"
00016     std::cout << object.at("the ugly") << '\n';
00017 
00018     // try to read from a nonexisting key
00019     try
00020     {
00021         std::cout << object.at("the fast") << '\n';
00022     }
00023     catch (std::out_of_range)
00024     {
00025         std::cout << "out of range" << '\n';
00026     }
00027 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:01