2017-08-29 23:46:26 +02:00
|
|
|
#include <iostream>
|
2018-02-01 22:20:26 +01:00
|
|
|
#include <nlohmann/json.hpp>
|
2017-08-29 23:46:26 +02:00
|
|
|
|
|
|
|
using json = nlohmann::json;
|
2022-07-31 17:38:52 +02:00
|
|
|
using namespace nlohmann::literals;
|
2017-08-29 23:46:26 +02:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// executing a failing JSON Patch operation
|
|
|
|
json value = R"({
|
|
|
|
"best_biscuit": {
|
|
|
|
"name": "Oreo"
|
|
|
|
}
|
|
|
|
})"_json;
|
|
|
|
json patch = R"([{
|
|
|
|
"op": "test",
|
|
|
|
"path": "/best_biscuit/name",
|
|
|
|
"value": "Choco Leibniz"
|
|
|
|
}])"_json;
|
|
|
|
value.patch(patch);
|
|
|
|
}
|
2023-09-23 17:19:50 +02:00
|
|
|
catch (const json::other_error& e)
|
2017-08-29 23:46:26 +02:00
|
|
|
{
|
|
|
|
// output exception information
|
|
|
|
std::cout << "message: " << e.what() << '\n'
|
|
|
|
<< "exception id: " << e.id << std::endl;
|
|
|
|
}
|
|
|
|
}
|