• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <iostream>
2 #include <nlohmann/json.hpp>
3 
4 using json = nlohmann::json;
5 using namespace nlohmann::literals;
6 
main()7 int main()
8 {
9     try
10     {
11         // executing a failing JSON Patch operation
12         json value = R"({
13             "best_biscuit": {
14                 "name": "Oreo"
15             }
16         })"_json;
17         json patch = R"([{
18             "op": "test",
19             "path": "/best_biscuit/name",
20             "value": "Choco Leibniz"
21         }])"_json;
22         value.patch(patch);
23     }
24     catch (json::other_error& e)
25     {
26         // output exception information
27         std::cout << "message: " << e.what() << '\n'
28                   << "exception id: " << e.id << std::endl;
29     }
30 }
31