pub fn resolve<'v>(value: &'v Value, path: &str) -> Result<&'v Value, FaceError>Expand description
Resolve a jq-like dotted/bracketed path against a Value.
§Path grammar
.— identity (returns the input unchanged)..foo.bar— nested object lookup..foo[0]— array index after a key..[0]— array index at the root.foo.bar— leading.is optional..foo[0].bar[1]— index chains accepted between segments.
§Errors
Returns FaceError::UnknownItemsPath when the path cannot be
resolved. The variant carries the original path string so the user
can identify which lookup failed; the variant choice is generic —
the score path code site re-wraps to
FaceError::UnknownScorePath when relevant.
§Examples
use face_core::path;
use serde_json::json;
let v = json!({"data": {"path": {"text": "src/lib.rs"}}});
let leaf = path::resolve(&v, "data.path.text").unwrap();
assert_eq!(leaf, &json!("src/lib.rs"));
let identity = path::resolve(&v, ".").unwrap();
assert_eq!(identity, &v);