@dsj9/jsonpath-rfc9535
v1.0.1
Published
High-performance JSONPath RFC 9535 implementation
Readme
@dsj9/jsonpath-rfc9535
A dependency-free TypeScript implementation of JSONPath RFC 9535 for Node.js 22.12 and newer. ESM and CommonJS are supported.
Install
npm install @dsj9/jsonpath-rfc9535Usage
import { compile, query } from '@dsj9/jsonpath-rfc9535';
const document = {
books: [
{ title: 'Kindred', price: 9 },
{ title: 'Dune', price: 12 },
],
};
query('$.books[[email protected] < 10].title', document);
// { nodes: [{ value: 'Kindred', path: "$['books'][0]['title']" }] }
const titles = compile('$.books[*].title');
titles.query(document);query(selector, document) parses and evaluates a selector. compile(selector) parses it once for reuse. Invalid selectors throw JsonPathSyntaxError.
Results contain each selected value and its RFC 9535 Normalized Path. The standard functions and RFC 9485 I-Regexps are supported. Custom function extensions are not currently supported.
Development
npm ci
npm run check
npm run benchBenchmark notes are in BENCHMARKS.md.
Correctness is tested against the JSONPath Compliance Test Suite. Benchmarks include a comparison with jsonpath-rfc9535.
MIT licensed. See LICENSE.
