6 releases (3 breaking)

new 0.4.0 Jan 2, 2025
0.3.2 Dec 23, 2024
0.3.1 Mar 28, 2024
0.3.0 Feb 29, 2024
0.1.0 Jan 10, 2024

#994 in Parser implementations

Download history 2/week @ 2024-09-11 3/week @ 2024-09-18 5/week @ 2024-09-25 4/week @ 2024-10-02 4/week @ 2024-10-16 64/week @ 2024-10-23 32/week @ 2024-10-30 24/week @ 2024-11-06 12/week @ 2024-11-13 8/week @ 2024-11-20 5/week @ 2024-11-27 12/week @ 2024-12-04 26/week @ 2024-12-11 125/week @ 2024-12-18 35/week @ 2024-12-25

200 downloads per month
Used in 3 crates

MIT license

235KB
4.5K SLoC

rsonpath-syntax – JSONPath parser

Rust docs.rs

Crates.io

MSRV License

Complete, fast, and fully spec-compliant JSONPath query parser.

Usage

Parse a query to its AST with the parse function.

let query = rsonpath_syntax::parse("$.jsonpath[*]")?;

For advanced usage consult the crate documentation.

Feature flags

There are three optional features:

  • arbitrary, which enables a dependency on the arbitrary crate to provide Arbitrary implementations on query types; this is used e.g. for fuzzing.
  • color, which enables a dependency on the owo_colors crate to provide colorful Display representations of ParseError with the colored function.
  • serde, which enables a dependency on the serde crate to provide serialization and deserialization of JsonPathQuery and all the underlying types.

Examples

There are two examples programs, builder showcases usage of the JsonPathQueryBuilder struct; cli is a small CLI tool that takes one argument, a query to parse, and prints a debug representation of the result query, or an error message – this is useful for debugging when developing the crate itself.

State of the crate

This is an in-development version that supports only name, index, and wildcard selectors. However, these are fully supported, tested, and fuzzed. The planned roadmap is:

  • support slices
  • support filters (without functions)
  • support functions (including type check)
  • polish the API
  • 1.0.0 stable release

Dependencies

Showing direct dependencies.

cargo tree --package rsonpath-lib --edges normal --depth 1 --target=all --all-features
rsonpath-syntax v0.4.0 (/home/mat/src/rsonpath/crates/rsonpath-syntax)
├── arbitrary v1.4.1
├── nom v7.1.3
├── owo-colors v4.1.0
├── serde v1.0.217
├── thiserror v2.0.9
└── unicode-width v0.2.0

Justification

  • arbitrary – optional Arbitrary support for fuzzing.
  • nom – combinator-based parsing used throughout the crate.
  • owo-colors – optional feature for pretty error messages.
  • serde – optional dependency for serialization and deserialization of compiled engines.
  • thiserror – idiomatic Error implementations.
  • unicode-width – used to display error messages correctly in presence of wider Unicode characters in the query string.

Dependencies

~3.5MB
~59K SLoC