Expand description
§Resolve values based on JSON Pointers
This module provides the Resolve and ResolveMut traits which are
implemented by types that can internally resolve a value based on a JSON
Pointer.
This module is enabled by default with the "resolve" feature flag.
§Usage
Resolve and ResolveMut can be used directly or through the
resolve and resolve_mut
methods on Pointer and PointerBuf.
use jsonptr::{Pointer, Resolve, ResolveMut};
use serde_json::json;
let ptr = Pointer::from_static("/foo/1");
let mut data = json!({"foo": ["bar", "baz"]});
let value = ptr.resolve(&data).unwrap();
assert_eq!(value, &json!("baz"));
let value = data.resolve_mut(ptr).unwrap();
assert_eq!(value, &json!("baz"));§Provided implementations
| Lang | value type | feature flag | Default |
|---|---|---|---|
| JSON | serde_json::Value | "json" | ✓ |
| TOML | toml::Value | "toml" |
Enums§
- Error
- Indicates that the
Pointercould not be resolved.
Traits§
- Resolve
- A trait implemented by types which can resolve a reference to a value type
from a path represented by a JSON
Pointer. - Resolve
Mut - A trait implemented by types which can resolve a mutable reference to a
value type from a path represented by a JSON
Pointer.
Type Aliases§
- Resolve
Error - Alias for
Error.