1#include <iostream>
2#include <nlohmann/json.hpp>
3
4using json = nlohmann::json;
5
6int main()
7{
8    try
9    {
10        // calling at() for an invalid index
11        json j = {1, 2, 3, 4};
12        j.at(4) = 10;
13    }
14    catch (json::out_of_range& e)
15    {
16        // output exception information
17        std::cout << "message: " << e.what() << '\n'
18                  << "exception id: " << e.id << std::endl;
19    }
20}
21