21 releases (breaking)

Uses new Rust 2024

0.18.0 May 19, 2025
0.15.0 Feb 25, 2025
0.14.0 Dec 26, 2024
0.12.0 Nov 25, 2024

#1405 in Parser implementations

Download history 1060/week @ 2025-02-03 1272/week @ 2025-02-10 1999/week @ 2025-02-17 1983/week @ 2025-02-24 1249/week @ 2025-03-03 1738/week @ 2025-03-10 987/week @ 2025-03-17 1119/week @ 2025-03-24 984/week @ 2025-03-31 1018/week @ 2025-04-07 1300/week @ 2025-04-14 2314/week @ 2025-04-21 4560/week @ 2025-04-28 2135/week @ 2025-05-05 2486/week @ 2025-05-12 1675/week @ 2025-05-19

11,197 downloads per month
Used in zizmor

MIT license

30KB
452 lines

yamlpath

CI Crates.io docs.rs

Format-preserving YAML feature extraction.

yamlpath uses tree-sitter and tree-sitter-yaml under the hood.

[!IMPORTANT]

This is not a substitute for full-fledged query languages or tools like JSONPath or jq.

Why?

YAML is an extremely popular configuration format, with an interior data model that closely resembles JSON.

It's common to need to analyze YAML files, e.g. for a security tool that needs to interpret the contents of a configuration file.

The normal way to do this is to parse the YAML into a document and interpret that document. However, that parsing operation is destructive: in producing a document model, it erases the comments and exact formatting of the YAML input.

This can make it difficult to present intelligible actions to uses, since users think in terms of changes needed on lines and columns and not changes needed to a specific sub-object within a document's hierarchy.

yamlpath bridges the gap between these two views: it allows a program to operate on the (optimal) document view, and then translate back to a human's understanding of the YAML input.

License

MIT License.

Dependencies

~4.5–6.5MB
~141K SLoC