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

Function erase1

examples/src/erase_examples.cpp:44–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43
44void erase1()
45{
46 try
47 {
48 // Read from input
49 std::istringstream is(input);
50 json instance = json::parse(is);
51
52 // Locate the item to be erased
53 auto it = std::find_if(instance.array_range().begin(), instance.array_range().end(),
54 [](const json& item){return item.at("id") == std::string("756746783");});
55
56 // If found, erase it
57 if (it != instance.array_range().end())
58 {
59 instance.erase(it);
60 }
61
62 // Write to output file
63 std::ostringstream os;
64 instance.dump_pretty(os);
65 std::cout << os.str() << "\n\n";
66 }
67 catch (const std::exception& e)
68 {
69 std::cout << e.what() << '\n';
70 }
71}
72
73void erase2()
74{

Callers 1

mainFunction · 0.85

Calls 6

parseFunction · 0.85
atMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected