MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / jsonpatch_add_add

Function jsonpatch_add_add

examples/src/jsonpatch_examples.cpp:11–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace jsonpatch = jsoncons::jsonpatch;
10
11void jsonpatch_add_add()
12{
13 // Apply a JSON Patch
14
15 json doc = json::parse(R"(
16 { "foo": "bar"}
17 )");
18
19 json doc2 = doc;
20
21 json patch = json::parse(R"(
22 [
23 { "op": "add", "path": "/baz", "value": "qux" },
24 { "op": "add", "path": "/foo", "value": [ "bar", "baz" ] }
25 ]
26 )");
27
28 std::error_code ec;
29 jsonpatch::apply_patch(doc, patch, ec);
30
31 std::cout << "(1)\n" << pretty_print(doc) << '\n';
32
33 // Create a JSON Patch
34
35 auto patch2 = jsonpatch::from_diff(doc2,doc);
36
37 std::cout << "(2)\n" << pretty_print(patch2) << '\n';
38
39 jsonpatch::apply_patch(doc2,patch2,ec);
40
41 std::cout << "(3)\n" << pretty_print(doc2) << '\n';
42}
43
44void jsonpatch_add_add_add_failed1()
45{

Callers 1

mainFunction · 0.85

Calls 4

parseFunction · 0.85
apply_patchFunction · 0.85
pretty_printFunction · 0.85
from_diffFunction · 0.50

Tested by

no test coverage detected