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