Crate json_patch_ext

Source
Expand description

This module provides some unofficial “extensions” to the jsonpatch format for describing changes to a JSON document. In particular, it adds the * operator as a valid token for arrays in a JSON document. It means: apply this change to all elements of this array. For example, consider the following document:

{
  "foo": {
    "bar": [
      {"baz": 1},
      {"baz": 2},
      {"baz": 3},
    ]
  }
}

The pathspec /foo/bar/*/baz would reference the baz field of all three array entries in the bar array. It is an error to use * to reference a field that is not an array. It is an error to use * at the end of a path, e.g., /foo/*.

Additionally, this crate will auto-create parent paths for the AddOperation only, e.g., the result of applying AddOperation{ path: "/foo/bar", value: 1 } to the empty document will be

{ "foo": {"bar": 1}}

Re-exports§

pub use json_patch::AddOperation;
pub use json_patch::CopyOperation;
pub use json_patch::MoveOperation;
pub use json_patch::Patch;
pub use json_patch::PatchOperation;
pub use json_patch::RemoveOperation;
pub use json_patch::ReplaceOperation;
pub use json_patch::TestOperation;

Modules§

prelude

Macros§

format_ptr

Structs§

Pointer
A JSON Pointer is a string containing a sequence of zero or more reference Tokens, each prefixed by a '/' character.
PointerBuf
An owned, mutable Pointer (akin to String).
Token
A Token is a segment of a JSON Pointer, preceded by '/' (%x2F).

Enums§

PatchError

Functions§

add_operation
copy_operation
escape
matches
move_operation
patch_ext
remove_operation
replace_operation
test_operation