- Update all packages to latest versions via pnpm update --latest - Downgrade Prisma 7 to 6 (v7 requires schema migration) - Downgrade Tailwind CSS 4 to 3 (v4 requires PostCSS migration) - Downgrade Storybook 10 to 8 (addons not available in v10) - Pin cheerio to 1.0.0-rc.12 via pnpm override (type exports changed) - Fix AI SDK tool definitions: parameters -> inputSchema - Fix cheerio types in extract-meta and table-extract tools - Add explicit type annotations to tool execute functions - Migrate biome config to v2.3.11 schema All type-checks, tests, and builds pass. |
||
|---|---|---|
| .. | ||
| src | ||
| CHANGELOG.md | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| tsup.config.ts | ||
@tpmjs/tools-json-path-query
Query JSON using JSONPath expressions.
Installation
npm install @tpmjs/tools-json-path-query
Usage
import { jsonPathQueryTool } from '@tpmjs/tools-json-path-query';
const data = {
users: [
{ name: 'Alice', age: 25, active: true },
{ name: 'Bob', age: 17, active: false },
{ name: 'Carol', age: 30, active: true }
]
};
// Find all active users
const result = await jsonPathQueryTool.execute({
json: data,
path: '$.users[?(@.active)].name'
});
console.log(result.results);
// => ["Alice", "Carol"]
console.log(result.count);
// => 2
console.log(result.paths);
// => ["$['users'][0]['name']", "$['users'][2]['name']"]
JSONPath Examples
// Get all user names
path: '$.users[*].name'
// Find users older than 18
path: '$.users[?(@.age > 18)]'
// Recursive descent - find all 'price' fields
path: '$..price'
// Array slicing - first 3 items
path: '$.items[0:3]'
// Multiple conditions
path: '$.users[?(@.age > 18 && @.active)]'
Features
- Powerful queries: Full JSONPath syntax support
- Filtering: Filter arrays with expressions like
?(@.age > 18) - Recursive descent: Find nested values with
.. - Path tracking: Returns the JSONPath to each result
- Array operations: Slicing, filtering, and wildcard selection
License
MIT