| 42 | |
| 43 | |
| 44 | void 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 | |
| 73 | void erase2() |
| 74 | { |