Skip to main content

create_patch

Function create_patch 

Source
pub fn create_patch(from: &Value, to: &Value) -> Patch
Expand description

Creates a JSON Patch representing the difference between two JSON values.

The patch, when applied to from, will produce to.

ยงExample

use ag_ui_core::patch::create_patch;
use serde_json::json;

let from = json!({"name": "Alice", "age": 30});
let to = json!({"name": "Alice", "age": 31});

let patch = create_patch(&from, &to);

// The patch contains a "replace" operation for the age field
assert!(!patch.0.is_empty());