pub fn apply_patch(target: &mut Value, patch: &Patch) -> Result<(), PatchError>Expand description
Applies a JSON Patch to a JSON value in place.
§Errors
Returns an error if any patch operation fails (e.g., path doesn’t exist for a remove operation, or test operation fails).
§Example
use ag_ui_core::patch::{create_patch, apply_patch};
use serde_json::json;
let mut state = json!({"count": 0});
let patch = create_patch(&json!({"count": 0}), &json!({"count": 5}));
apply_patch(&mut state, &patch).unwrap();
assert_eq!(state["count"], 5);