JSONPath Query API
Extract values from JSON with JSONPath (RFC 9535: wildcards, recursive descent, slices, filters with functions) or JSON Pointer, with the path of each result.
The JSON query API evaluates a JSONPath expression on a JSON document and returns the matching values with their normalised paths. It implements RFC 9535: member and index selectors ($.store.book[0], $["key with spaces"], negative indexes), wildcards, recursive descent ($..price), slices with steps ([1:5:2], [::-1]), unions ([0,2]) and filters such as $..book[?@.price < 10 && @.category == "fiction"].title.
Filters support existence tests ([?@.isbn]), comparisons of numbers and strings, &&, ||, !, parentheses, references to the root ($) and the functions length(), count(), match() and search() (regular expressions, with the same protection against runaway patterns as the regex API).
Pass pointer=/store/book/1/title instead of path to read one value with a JSON Pointer (RFC 6901). Results are limited to 10,000 values (limit, default 1,000).
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
json | body | object | yes | The JSON document (object or JSON string). | |
path | body|query | string | no | JSONPath expression starting with $. | |
pointer | body|query | string | no | JSON Pointer instead of path, e.g. /a/0. | |
limit | body|query | number | no | 1000 | Maximum number of values returned. |
Example
curl -X POST "https://apibox.io.vn/v1/json-query" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"json":{"store":{"book":[{"title":"Sayings","price":8.95},{"title":"Sword","price":12.99},{"title":"Moby Dick","price":8.99,"isbn":"0-553-21311-3"}]}},"path":"$..book[?@.price < 10].title"}'const res = await fetch('https://apibox.io.vn/v1/json-query', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"json": {
"store": {
"book": [
{
"title": "Sayings",
"price": 8.95
},
{
"title": "Sword",
"price": 12.99
},
{
"title": "Moby Dick",
"price": 8.99,
"isbn": "0-553-21311-3"
}
]
}
},
"path": "$..book[?@.price < 10].title"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/json-query",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"json": {"store": {"book": [{"title": "Sayings", "price": 8.95}, {"title": "Sword", "price": 12.99}, {"title": "Moby Dick", "price": 8.99, "isbn": "0-553-21311-3"}]}}, "path": "$..book[?@.price < 10].title"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/json-query');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"json":{"store":{"book":[{"title":"Sayings","price":8.95},{"title":"Sword","price":12.99},{"title":"Moby Dick","price":8.99,"isbn":"0-553-21311-3"}]}},"path":"$..book[?@.price < 10].title"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"path": "$..book[?@.price < 10].title",
"count": 2,
"truncated": false,
"values": [
"Sayings",
"Moby Dick"
],
"paths": [
"$['store']['book'][0]['title']",
"$['store']['book'][2]['title']"
]
}
Use cases
- Pick fields from third-party API responses in no-code tools
- Test JSONPath expressions before using them in code or monitoring
- Extract values from large JSON exports
- Teach and debug JSONPath
FAQ
Which JSONPath dialect is this?
RFC 9535, the 2024 IETF standard, which matches the original Goessner syntax for the common cases. The older ?(@.x) filter form with parentheses is accepted too.
What does each result path look like?
Normalised paths such as $['store']['book'][0]['title'], one per value, in the same order.
Can I query with JSON Pointer?
Yes, pointer=/a/0/b returns one value and found=false when it does not exist.
Related APIs
JSON Validator
Check JSON syntax with exact line and column of errors, and validate data against a JSON Schema (draft 4, 7, 2019-09 or 2020-12).
{ }JSON Formatter
Pretty print JSON with 0-8 spaces or tabs, minify it, or sort object keys recursively. Syntax errors are reported with line and column.
CSVCSV to JSON
Convert CSV into an array of JSON objects using the header row, with delimiter auto-detection, number and boolean typing, and row-level errors.