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 object =
00009 {
00010 {"the good", "il buono"},
00011 {"the bad", "il cativo"},
00012 {"the ugly", "il brutto"}
00013 };
00014
00015
00016 std::cout << object.at("the ugly") << '\n';
00017
00018
00019 object.at("the bad") = "il cattivo";
00020
00021
00022 std::cout << object << '\n';
00023
00024
00025 try
00026 {
00027 object.at("the fast") = "il rapido";
00028 }
00029 catch (std::out_of_range& e)
00030 {
00031 std::cout << "out of range: " << e.what() << '\n';
00032 }
00033 }