| 5 | namespace Star { |
| 6 | |
| 7 | Json jsonPatch(Json const& base, JsonArray const& patch) { |
| 8 | auto res = base; |
| 9 | try { |
| 10 | for (auto const& operation : patch) { |
| 11 | res = JsonPatching::applyOperation(res, operation); |
| 12 | } |
| 13 | return res; |
| 14 | } catch (JsonException const& e) { |
| 15 | throw JsonPatchException(strf("Could not apply patch to base. {}", e.what()), false); |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | |
| 20 | // Returns 0 if not found, index + 1 if found. |