Module resolve

Source
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

Langvalue typefeature flagDefault
JSONserde_json::Value"json"
TOMLtoml::Value"toml"

Enums§

Error
Indicates that the Pointer could 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.
ResolveMut
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§

ResolveError
Alias for Error.