json-patch icon indicating copy to clipboard operation
json-patch copied to clipboard

`diff()` produces invalid patches for root replacements

Open Ereski opened this issue 5 years ago • 0 comments

The following will fail with an invalid pointer error:

let mut a = serde_json::Value::from(0);
let b = serde_json::Value::from(1);
let patch = json_patch::diff(&a, &b);
json_patch::patch(&mut a, &patch).unwrap();

The problem is that diff() generates a replacement with / as the path, which then can't be applied.

Ereski avatar Jan 18 '21 15:01 Ereski