9 releases
Uses new Rust 2024
| 0.3.3 | Mar 10, 2026 |
|---|---|
| 0.3.2 | Feb 1, 2026 |
| 0.3.0 | Jun 30, 2025 |
| 0.2.2 | Mar 28, 2025 |
| 0.1.1 | Nov 22, 2024 |
#1419 in Encoding
1,914 downloads per month
Used in 2 crates
22KB
500 lines
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}}
json-patch-ext
Unofficial extensions and helper functions for the json-patch crate.
Features
- Support for the
*operator when adding/replacing/removing elements: applies the operation to all elements in the array at that location in the path - Some nice utility functions for constructing patches
- Automatically create parent references in an add operation: e.g., if your path is
/foo/bar/baz, and your JSON object looks like{"foo": {}}, the result of the add operation will be{"foo": {"bar": {"baz": <value>}}}. matchesfunction returns the matching paths and values for a query string
Dependencies
~0.7–1.6MB
~33K SLoC