@tpmjs/tools-json-path-query
Query JSON data using JSONPath expressions. Supports filtering, recursive descent, and complex queries like "$.users[?(@.age > 18)].name" or "$..book[?(@.price < 10)]".
Test @tpmjs/tools-json-path-query (jsonPathQueryTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-json-path-querypnpm add @tpmjs/tools-json-path-queryyarn add @tpmjs/tools-json-path-querybun add @tpmjs/tools-json-path-querydeno add npm:@tpmjs/tools-json-path-queryimport { jsonPathQueryTool } from '@tpmjs/tools-json-path-query';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { jsonPathQueryTool } from '@tpmjs/tools-json-path-query';
const result = await generateText({
model: openai('gpt-4o'),
tools: { jsonPathQueryTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
jsonobjectarrayJSON data to query (object or array)
pathstringJSONPath expression (e.g., "$.users[*].name", "$..price", "$.items[?(@.active)]")
Schema extracted: 1/1/2026, 8:18:12 AM
Query JSON using JSONPath expressions.
npm install @tpmjs/tools-json-path-query
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']"]
// 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)]'
?(@.age > 18)..MIT
Downloads/month
0
Quality Score