Test and evaluate JSONPath expressions online. Filter, slice, and extract data from JSON documents instantly.
$ Root object@ Current object. Child operator.. Recursive descent* Wildcard[n] Array index[start:end] Array slice[?(@.age > 10)] FilterJSONPath is a query language for JSON, similar to XPath for XML. It allows you to select and extract data from a JSON document. Our JSONPath Tester provides an interactive environment to write queries and see results in real-time, all processed locally in your browser for maximum privacy.
$.store.book[*].author).$: The root object/element.. or []: Child operator to access properties...: Recursive descent (deep scan).*: Wildcard, matches all objects/elements.[start:end:step]: Array slicing.Implement JSONPath in your applications using popular libraries for different languages.
Using the jsonpath library:
const jp = require('jsonpath');
const data = {
store: {
book: [
{ category: "reference", author: "Nigel Rees", title: "Sayings of the Century", price: 8.95 },
{ category: "fiction", author: "Evelyn Waugh", title: "Sword of Honour", price: 12.99 }
]
}
};
// Extract all authors
const authors = jp.query(data, '$.store.book[*].author');
console.log(authors); // ["Nigel Rees", "Evelyn Waugh"]Using jsonpath-ng:
from jsonpath_ng import jsonpath, parse
json_data = {
'foo': [{'baz': 1}, {'baz': 2}]
}
jsonpath_expression = parse('foo[*].baz')
match = [match.value for match in jsonpath_expression.find(json_data)]
print(match) # [1, 2]Using Jayway JsonPath:
import com.jayway.jsonpath.JsonPath;
String json = "..."; // your json string
List authors = JsonPath.read(json, "$.store.book[*].author");
System.out.println(authors);