Packages / rupm

json-merge-tools 0.1.0

JSON Merge Patch (RFC 7386) and JSON Patch (RFC 6902) with JSON Pointer, for serde_json values

Install

cargo add json-merge-tools --registry rupm

In Ruststudio: Packages, search for json-merge-tools, Install.

Owner: Rust Studio. Licence: MIT OR Apache-2.0. Total downloads: 0. Published 2026-11-22.

Versions

README

# json-merge-tools

JSON Merge Patch (RFC 7386) and JSON Patch (RFC 6902) with JSON Pointer, for serde_json values

Add it with `rupm add json-merge-tools` (or `cargo add json-merge-tools --registry rupm`).

```rust
use json_merge_tools::{apply_patch, merge_patch};
use serde_json::json;

// RFC 7386: objects merge, null deletes, everything else replaces.
let mut doc = json!({"title": "Hello", "author": {"name": "Ann", "email": "a@x.org"}});
merge_patch(&mut doc, &json!({"title": "Hi", "author": {"email": null}}));
assert_eq!(doc, json!({"title": "Hi", "author": {"name": "Ann"}}));

// RFC 6902: a list of operations, applied all or nothing.
let mut doc = json!({"tags": ["a"]});
apply_patch(&mut doc, &json!([
    {"op": "add", "path": "/tags/-", "value": "b"},
    {"op": "replace", "path": "/tags/0", "value": "z"},
    {"op": "test", "path": "/tags/1", "value": "b"}
])).unwrap();
assert_eq!(doc, json!({"tags": ["z", "b"]}));
```