jsonpath-js
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

jsonpath-js

GitHub License NPM Version Link Checker

[!WARNING] This library is still in its initial development stage, so please be aware that the API is subject to change.

An implementation of RFC 9535 JSONPath

Features

  • 100% Compatible with RFC 9535

Supported Runtimes

  • Node v20+
  • Deno v2+
  • Bun v1.2+

Install

npm install jsonpath-js

Usage

import { JSONPathJS } from "jsonpath-js";

const query = new JSONPathJS("$.users[*].name");
const result = query.find({
  users: [{ name: "John Doe" }, { name: "Jane Doe" }],
});

// [ 'John Doe', 'Jane Doe' ]
console.log(result);


const pathResult = query.paths({
	users: [{ name: "John Doe" }, { name: "Jane Doe" }],
});

// [
// 	{ value: "John Doe", path: "$['users'][0]['name']" },
// 	{ value: "Jane Doe", path: "$['users'][1]['name']" },
// ];
console.log(pathResult);

Contributing

Please read the contributing guide.

Readme

Keywords

Package Sidebar

Install

npm i jsonpath-js

Weekly Downloads

10,450

Version

0.2.0

License

MIT

Unpacked Size

225 kB

Total Files

162

Last publish

Collaborators

  • ashphy