Go to the documentation of this file.00001 #include <json.hpp>
00002
00003 using json = nlohmann::json;
00004
00005 int main()
00006 {
00007
00008 json array = {"first", "2nd", "third", "fourth"};
00009
00010
00011 std::cout << array.at(2) << '\n';
00012
00013
00014 array.at(1) = "second";
00015
00016
00017 std::cout << array << '\n';
00018
00019
00020 try
00021 {
00022 array.at(5) = "sixth";
00023 }
00024 catch (std::out_of_range& e)
00025 {
00026 std::cout << "out of range: " << e.what() << '\n';
00027 }
00028 }