merge

Function merge 

Source
pub fn merge(doc: &mut Value, patch: &Value)
Expand description

Patch provided Platform Value document (given as platform_value::Value) in place with Platform Value Merge Patch (RFC 7396).

ยงExample

Create and patch document:

#[macro_use]
use platform_value::{patch::merge, platform_value};

let mut doc = platform_value!({
  "title": "Goodbye!",
  "author" : {
    "givenName" : "John",
    "familyName" : "Doe"
  },
  "tags":[ "example", "sample" ],
  "content": "This will be unchanged"
});

let patch = platform_value!({
  "title": "Hello!",
  "phoneNumber": "+01-123-456-7890",
  "author": {
    "familyName": null
  },
  "tags": [ "example" ]
});

merge(&mut doc, &patch);

assert_eq!(doc, platform_value!({
  "title": "Hello!",
  "author" : {
    "givenName" : "John"
  },
  "tags": [ "example" ],
  "content": "This will be unchanged",
  "phoneNumber": "+01-123-456-7890"
}));