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