at__size_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 array
00008     json array = {"first", "2nd", "third", "fourth"};
00009 
00010     // output element at index 2 (third element)
00011     std::cout << array.at(2) << '\n';
00012 
00013     // try to read beyond the array limit
00014     try
00015     {
00016         std::cout << array.at(5) << '\n';
00017     }
00018     catch (std::out_of_range)
00019     {
00020         std::cout << "out of range" << '\n';
00021     }
00022 }


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