Skip to main content

Crate yaml_rt_rfc9535

Crate yaml_rt_rfc9535 

Source
Expand description

Native RFC 9535 JSONPath queries over yaml-rt semantic documents.

Queries are parsed once and can be evaluated repeatedly without converting YAML into an intermediate JSON value tree.

use yaml_rt_core::YamlDoc;
use yaml_rt_rfc9535::JsonPath;

let doc = YamlDoc::parse("users: [{name: Ada}, {name: Linus}]\n")?;
let path = JsonPath::parse("$.users[*].name")?;
let matches = path.query(&doc, 0)?;
let pointers = matches
    .iter()
    .map(|matched| matched.pointer().as_str())
    .collect::<Vec<_>>();
assert_eq!(pointers, ["/users/0/name", "/users/1/name"]);

Structs§

Error
A structured JSONPath parse or evaluation error.
JsonPath
A parsed and reusable RFC 9535 JSONPath query.
QueryMatch
One located JSONPath match.
QueryMatches
Ordered JSONPath query results.

Enums§

ErrorKind
Classification of a JSONPath parse or evaluation failure.