Crate json_patch [−] [src]
JSON-Patch RFC 6902, JavaScript Object Notation (JSON) Patch implementation.
JSON-Patch implementation based on serde_json
crate.
Usage
Add this to your Cargo.toml:
toml [dependencies] json-patch = "*"
Examples
Create and patch document:
#[macro_use] extern crate serde_json; extern crate json_patch; use json_patch::patch; use serde_json::from_str; let mut doc = json!([ { "name": "Andrew" }, { "name": "Maxim" } ]); let p = from_str(r#"[ { "op": "test", "path": "/0/name", "value": "Andrew" }, { "op": "add", "path": "/0/happy", "value": true } ]"#).unwrap(); patch(&mut doc, &p).unwrap(); assert_eq!(doc, json!([ { "name": "Andrew", "happy": true }, { "name": "Maxim" } ]));
Structs
AddOperation |
JSON Patch 'add' operation representation |
CopyOperation |
JSON Patch 'copy' operation representation |
MoveOperation |
JSON Patch 'move' operation representation |
Patch |
Representation of JSON Patch (list of patch operations) |
RemoveOperation |
JSON Patch 'remove' operation representation |
ReplaceOperation |
JSON Patch 'replace' operation representation |
TestOperation |
JSON Patch 'test' operation representation |
Enums
PatchError |
This type represents all possible errors that can occur when applying JSON patch |
PatchOperation |
JSON Patch single patch operation |
Functions
from_value |
Create JSON Patch from JSON Value |
patch |
Patch provided JSON document (given as |
patch_unsafe⚠ |
Patch provided JSON document (given as |