pub fn apply_patch_from_value(
target: &mut Value,
patch: &Value,
) -> Result<(), PatchError>Expand description
Applies a JSON Patch from a JSON array representation.
This is useful when you receive patches as raw JSON values (e.g., from network events).
§Errors
Returns an error if the patch is not a valid JSON Patch array or if any operation fails.
§Example
use ag_ui_core::patch::apply_patch_from_value;
use serde_json::json;
let mut state = json!({"count": 0});
let patch_json = json!([
{"op": "replace", "path": "/count", "value": 10}
]);
apply_patch_from_value(&mut state, &patch_json).unwrap();
assert_eq!(state["count"], 10);