jsonptr
Data structures and logic for resolving, assigning, and deleting JSON data by RFC 6901 pointers in Rust.
Repository Health
Technical Analysis
jsonptr is a Rust crate implementing JSON Pointers as defined by RFC 6901, the string syntax for identifying a specific location within a JSON or JSON-like document. It provides two core types, Pointer and PointerBuf (mirroring the standard library’s Path and PathBuf), for constructing, parsing, and manipulating pointers abstractly.
Beyond addressing, the crate supplies logic to resolve values at a pointer, assign new values (creating intermediate structures as needed), and delete values, with modular feature flags, no_std support, and optional integrations for serde, serde_json, and miette diagnostics.
What You Get
- Typed
PointerandPointerBufvalues mirroringPath/PathBuffor borrowed and owned pointers - Full RFC 6901 parsing and token handling, including escaping rules for
~and/ - Resolve, assign, and delete operations against JSON documents, each behind its own feature flag
- Optional serde and serde_json integration plus miette-powered diagnostics for parse errors
no_stdsupport via thealloccrate and a modular default feature set
Common Use Cases
- Addressing and extracting a nested value from a JSON document by pointer string
- Applying JSON Patch-style assignments that create intermediate objects and arrays as needed
- Deleting a value at a specific pointer location within a mutable JSON structure
Under The Hood
Architecture - The crate centers on the Pointer/PointerBuf pair in src/pointer.rs, built from Token segments (src/token.rs) and Components (src/component.rs), with array-index handling in src/index.rs. The three document operations live in src/resolve.rs, src/assign.rs, and src/delete.rs, each exposed behind a matching Cargo feature, while src/diagnostic.rs provides rich error reporting.
Tech Stack - Pure Rust (edition 2021, MSRV 1.79) with all external dependencies optional: serde and serde_json (alloc-only by default), toml, and miette for fancy diagnostics. A granular feature matrix (std, serde, json, resolve, assign, delete, miette) lets consumers compile a minimal no_std build or a full-featured one.
Code Quality - Tests are colocated across nearly every module (resolve.rs, assign.rs, delete.rs, token.rs, index.rs, and more) and the project uses quickcheck for property-based testing plus codecov coverage tracking and CI. An arbitrary.rs module supports fuzzing-style input generation.
API Design - Modeling pointers on the familiar Path/PathBuf split makes the API immediately intuitive to Rust developers, and the resolve/assign/delete verbs map cleanly to document operations. Extensive docs.rs documentation and a detailed README keep the learning curve gentle despite the crate’s flexibility.